28.12.2014, 15:29
Trying to do a /callsign system on a roleplay server, which basically adds a vurable to player CallSign[playerid][256];
and when uses /callsigns a dialog style list opens and his options are the callsign names, when picking them it sends a MSGBOX dialog which shows him the players who has that callsign:
and when uses /callsigns a dialog style list opens and his options are the callsign names, when picking them it sends a MSGBOX dialog which shows him the players who has that callsign:
Код:
CMD:callsign(playerid, params[]) { new string[128]; if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(!IsAOfficer(playerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not in the LSPD/SASD."); if(!PlayerInfo[playerid][pFacDuty]) return SendClientMessage(playerid, COLOR_LIGHTRED, "You can't use this command while not on duty."); if(sscanf(params,"s[128]",params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /callsign [CALLSIGN]"); if(!strcmp(params, "none", true)) { format(CallSign[playerid], 256, ""); HasCallSign[playerid] = 0; SendClientMessage(playerid, COLOR_GREEN, "You have set your callsign to none."); } else { format(CallSign[playerid], 256, "%s", params); format(string, sizeof(string), "** HQ: %s %s is now under %s. **", RPFRN(playerid), RPN(playerid), params); SendPlayerFactionMessage(playerid, 0, COLOR_COP, string); HasCallSign[playerid] = 1; } return 1; } CMD:callsigns(playerid, params[]) { if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(!IsAOfficer(playerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not in the LSPD/SASD."); if(!PlayerInfo[playerid][pFacDuty]) return SendClientMessage(playerid, COLOR_LIGHTRED, "You can't use this command while not on duty."); if(!PlayerInfo[playerid][pCallSignPerm]) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command."); ShowDialog(playerid, 45); return 1; }
Код:
case 45: //callsigns { new string1[256], duty; foreach(Player, i) { if(PlayerInfo[playerid][pFac] == PlayerInfo[i][pFac]) { if(PlayerInfo[i][pFacDuty] && IsAOfficer(i)) { if(HasCallSign[i]) { duty ++; } } } } for(new i = 0; i < MAX_PLAYERS; i++) { if(PlayerInfo[playerid][pFac] == PlayerInfo[i][pFac]) { if(HasCallSign[i] && PlayerInfo[i][pFacDuty]) { if(duty >= 1) { format(string1,sizeof(string1),"%s CALLSIGNS", RPFN(playerid)); format(string,sizeof(string),"%s %s\n", string, CallSign[i]); format(callsigner[playerid], 256, "%s", CallSign[i]); ShowPlayerDialog(playerid, 46, DIALOG_STYLE_LIST, string1, string, "View", "Cancel"); } } } } }
Код:
else if(dialogid == 46) { if(response) { new string1[256]; new string[256]; switch(listitem) { case 0: { format(string,sizeof(string), "%s", callsigner[playerid]); for(new i = 0; i < MAX_PLAYERS; i++) { if(format(callsigner[playerid], 256, "", CallSign[i]) == format(CallSign[i], 256, "", CallSign[i])) { format(string1,sizeof(string1), "{0x8f90fdFF}%s %s\n", string1, RPN(i)); } } ShowPlayerDialog(playerid, 47, DIALOG_STYLE_MSGBOX, string, string1, "CONFIRM", ""); } } } return 1; } else if(dialogid == 47) { if(response) { ShowDialog(playerid, 45); } }