Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //O sa definim numarul armelor totale
- #define ORDER_WEAPONS 3
- //adaugam in enum (sau define, depinde cum lucrati) un dialog
- DIALOG_ORDER
- //Adaugam armele dorite de noi intr-un array
- new orderWeapons[ORDER_WEAPONS] = {
- WEAPON_DEAGLE, WEAPON_M4, WEAPON_RIFLE
- };
- //La enum-ul vostru adaugati urmatoarea variabila, ca mai jos
- pOrderWeapons[ORDER_WEAPONS];
- //Veti adauga field-ul OrderWeapons in vaza de date, ca variabila de tip varchar
- //La logarea jucatorului pe server, vom lua armele din baza de date
- new string[64];
- cache_get_field_content(0, "OrderWeapons", string);
- sscanf(string, "p<|>iii", PlayerInfo[playerid][pOrderWeapons][0],
- PlayerInfo[playerid][pOrderWeapons][1], PlayerInfo[playerid][pOrderWeapons][2]);
- //Cateva functii de care ne vom folosi
- stock getOrderWeapons(playerid) {
- new count = 0;
- for(new i = 0; i < ORDER_WEAPONS; i++) {
- if(!PlayerInfo[playerid][pOrderWeapons][i]) {
- count ++;
- }
- }
- return count;
- }
- stock orderWeaponsUpdate(playerid) {
- new string[64], query[128];
- for(new i = 0; i < ORDER_WEAPONS; i++) {
- if(i == ORDER_WEAPONS - 1) format(string, sizeof string, "%s%d", string, PlayerInfo[playerid][pOrderWeapons][i]);
- else format(string, sizeof string, "%s%d|", string, PlayerInfo[playerid][pOrderWeapons][i]);
- }
- mysql_format(SQL, query, sizeof query, "UPDATE `users` SET `OrderWeapons` = '%s' WHERE `id` = '%d'", string, PlayerInfo[playerid][pSQLID]);
- mysql_tquery(SQL, query, "", "");
- return 1;
- }
- //Comenzile propriu-zise:
- CMD:order(playerid, params[], help) {
- if(!getOrderWeapons(playerid)) return SCM(playerid, -1, "Nu ai nici o arma setata [/setguns].");
- new count = 0;
- for(new i = 0; i < ORDER_WEAPONS; i++) {
- if(!PlayerInfo[playerid][pOrderWeapons][i]) {
- GivePlayerWeapon(playerid, orderWeapons[i], 100);
- count ++;
- }
- }
- new string[128];
- format(string, sizeof string, "(Order): {ffffff}Ai luat %d %s din seif.", count, (count == 1) ? ("arma") : ("arme"));
- SCM(playerid, 0x009999FF, string);
- return 1;
- }
- CMD:setguns(playerid, params[], help) {
- new string[128], weaponName[30];
- format(string, sizeof string, "Arma\tStatus\n");
- for(new i = 0; i < ORDER_WEAPONS; i++) {
- GetWeaponName(orderWeapons[i], weaponName, 30);
- format(string, sizeof string, "%s%s\t%s\n", string, weaponName, (!PlayerInfo[playerid][pOrderWeapons][i]) ? ("{d90909}neutilizat") : ("{27c42a}utilizat"));
- }
- ShowPlayerDialog(playerid, DIALOG_ORDER, DIALOG_STYLE_TABLIST_HEADERS, "Order:", string, "Select", "Exit");
- return 1;
- }
- //Dialogul
- if(dialogid == DIALOG_ORDER)
- {
- if(!response) return 1;
- PlayerInfo[playerid][pOrderWeapons][listitem] = (!PlayerInfo[playerid][pOrderWeapons][listitem]) ? (1) : (0);
- orderWeaponsUpdate(playerid);
- // in cazul in care folositi YCMD, veti folosi:
- Command_ReProcess(playerid, "setguns", false);
- // in cazul in care folositi oricare alt procesor de comenzi, cum ar fii zcmd, veti folosi:
- cmd_setguns(playerid);
- new string[128], weaponName[30];
- GetWeaponName(orderWeapons[listitem], weaponName, 30);
- format(string, sizeof string, "(Order): {ffffff}Arma %s: %s{ffffff}.", weaponName, (!PlayerInfo[playerid][pOrderWeapons][i]) ? ("{d90909}neutilizat") : ("{27c42a}utilizat"));
- SCM(playerid, 0x009999FF, string);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement