ZeCo Posted November 9, 2018 Share Posted November 9, 2018 Salut, acest sistem ajuta in perioadada sarbatorilor sa plasam obiecte pe serverul nostru si atunci cand cineva trece prin obiect, primeste un premiu. Tin sa mentionez ca acest sistem nu este 100% facut de mine, am luat acest sistem dintr-un anumit GM si l-am refacut 90%, era un simplu sistem de event care trebuia sa gaesesti un obiect, era mereu acel obiect si aceiasi suma de bani, si nu se putea sterge obiectul, doar cand intra un jucator prin el. In primul rand, adaugam asta la inceputul GameMode-ului, doar daca vrei sa aveti prescurtarea din SendClientMessage in SCM. Daca nu inlocuiti totul unde scrie SCM in SendClientMessage. #define SCM SendClientMessage Puteti folosi SCM oriunde in locului la SendClientMessage. La PlayerInfo puteti folosi PlayerData, sau ce aveti voi in GM. Dupa adaugam variabile enum objInfo { ObjectMoney, ObjectEvent } new ObjectInfo[MAX_OBJECTS][objInfo]; Acum, adaugam comanda. CMD:addobject(playerid, params[]) { new obj; if(PlayerInfo[playerid][pAdmin] < 6) return 1; if(sscanf(params, "ii", obj, ObjectMoney)) { SCM(playerid, COLOR_GREY, "Sintaxa: {FFFFFF}/addobject <object id> <money>"); return 1; } new id = GetObjects(), Float: Pos[3]; if(id == MAX_COBJECTS) return SCM(playerid, COLOR_YELLOW2, "A fost atinsa limita maxima de obiecte."); if(obj < 1 || obj > 19500) return SCM(playerid, COLOR_GREY, "Acest obiect este invalid."); if(money < 1 || money > 100000) return SCM(playerid, COLOR_GREY, "Aceasta suma este invalida. ($1-$100,000)"); // aceqasta suma o pueti seta chiar voi (premiul maxim) GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]); ObiecteEvent = CreateDynamicPickup(obj, 23, Pos[0], Pos[1], Pos[2], 0, -1, -1, 100.0); SCM(playerid, COLOR_WHITE,"Ai plasat un obiect."); return 1; } Dupa cautam „public OnPlayerPickUpDynamicPickup(playerid, pickupid)” si adaugam: for(new i = 0; i < MAX_COBJECTS; i++) { if(ObiecteEvent != 0) { if(pickupid == ObiecteEvent) { new id = GetObjects(); if(PlayerInfo[playerid][pAdmin] != 0) return 1; // aceasta functie inpiedica ca un admin sa poate primi premiul, daca nu vreti acest lucru il pueti sterge. GivePlayerCash(playerid, ObjectMoney); if(id == 1) { format(str, 256, "Info: %s a gasit obiectul si a castigat suma de $%s.", GetName(playerid), FormatNumber(ObjectMoney)); SCM(COLOR_ORANGE, str); } else { format(str, 256, "Info: %s a gasit unul dintre obiecte si a castigat suma de $%s.", GetName(playerid), FormatNumber(ObjectMoney)); SCM(COLOR_ORANGE, str); format(str, 256, "Info: In acest moment, mai sunt %d obiecte.", id-1); SendClientMessageToAll(COLOR_ORANGE, str); } RemoveObject(i); } } } Dupa, adaugam comanda pentru a sterge obiectul sau obiectele. CMD:removeobjects(playerid, params[]) { new id = GetObjects(); if(PlayerInfo[playerid][pAdmin] < 6) return 1; if(id == 0) return SCM(playerid, COLOR_GREY, "Nu sunt obiecte create."); new obj = GetObjects(); new string[180]; format(string, sizeof(string), "AdmCmd: %s a sters toate obiectele create (%d).", GetName(playerid), obj); SendAdminMessage(COLOR_LOGS, string, 2); RemoveObjects(); return 1; } Si dupa adaugam functia ”RemoveObjects” si RemoveObject. RemoveObject este atunci cand un player trece prin acest obiect si primeste un premiu. Obiectul va disparea si premiul se va reseta. function RemoveObject(id) { DestroyDynamicPickup(ObiecteEvent); ObiecteEvent = 0; ObjectMoney = 0; return 1; } Si acum adaugam RemoveObjects, este atunci cand un Administrator de pe server sterge obiectul din anumite motive, chiar si atunci cand nu a trecut nici un jucator prin el si premiul se va reseta la 0. function RemoveObjects() { for(new i = 0; i < MAX_COBJECTS; i++) { if(ObiecteEvent != 0) { DestroyDynamicPickup(ObiecteEvent); ObiecteEvent = 0; ObjectMoney = 0; } } return 1; } Link to comment Share on other sites More sharing options...
RokkY Posted November 15, 2018 Share Posted November 15, 2018 Nice , il voi folosii si eu Link to comment Share on other sites More sharing options...
ZeCo Posted November 16, 2018 Author Share Posted November 16, 2018 Topic Closed. Link to comment Share on other sites More sharing options...
Recommended Posts