22.12.2013, 19:05
Hey guys.
I have made a /requesthelp command for moderators to come and help players in need. But it is bugged and I cant see why it is. If I /requesthelp and then my brother /accepthr it keeps saying it is an invalid report. Here is the code:
I would also like it so when someone finishes the helprequest it resets the "RID" so the next person to /requesthelp gets the "RID'
I have made a /requesthelp command for moderators to come and help players in need. But it is bugged and I cant see why it is. If I /requesthelp and then my brother /accepthr it keeps saying it is an invalid report. Here is the code:
Код:
CMD:requesthelp(playerid, params[]) { new hr[168], str[168]; if(sscanf(params, "s[168]", hr)) return SendClientMessage(playerid, -1, "USAGE: /requesthelp [text]"); if(helprequested[playerid] == 1) return SendClientMessage(playerid, -1, "You already have an active request."); // if(helprequests > 999) hr = 0; helprequests++; helprequested[playerid] = 1; helprequestid[playerid] = helprequests; format(str, sizeof(str), "
from %s [RID: %i]: %s", GetName(playerid), helprequests, hr); format(helprequesttext[playerid], sizeof(helprequesttext), "%s [ID: %i] [RID: %i]: %s", GetName(playerid), playerid, helprequests, hr); SendClientMessageToModsDuty(COLOR_CYAN, str, 1); return 1; }
Код:
CMD:accepthr(playerid, params[]) { new rid; new Float:x, Float:y, Float:z; if(PlayerInfo[playerid][pModerator] <= 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command yet!"); if(CDuty[playerid] != 1) return SendClientMessage(playerid,COLOR_WHITE, "You are not on duty!"); if(sscanf(params, "i", rid)) return SendClientMessage(playerid, -1, "USAGE: /accepthr [RID]"); if(rid == 0) return SendClientMessage(playerid, -1, "Invalid Report ID. Use the report ID - Not the playerid / name."); new success = 0; for(new p;p<MAX_PLAYERS;p++) { if(helprequestid[p] == rid) { new str2[126]; format(str2, sizeof(str2), "%s has accepted the help request [RID: %d]", GetName(playerid), rid); SendClientMessageToModeratorsEx(COLOR_CYAN, str2, 1); helprequested[p] = 0; helprequestid[p] = 0; GetPlayerPos(playerid, PlayerInfo[playerid][pAx], PlayerInfo[playerid][pAy], PlayerInfo[playerid][pAz]); GetPlayerPos(p, x, y, z); SetPlayerPos(playerid, x+1, y+1, z); SetTimerEx("HelpRequest", 1000, false, "d", playerid); return 1; } else { if(success == 0) SendClientMessage(playerid, -1, "That is not a valid report!"); return 1; } } return 1; }
Код:
CMD:finishhr(playerid, params[]) { new rid, str[126]; if(PlayerInfo[playerid][pModerator] <= 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command yet!"); for(new p;p<MAX_PLAYERS;p++) if(helprequestid[p]) { format(str, sizeof(str), "%s has finished a help request", GetName(playerid), rid); SendClientMessageToModeratorsEx(COLOR_CYAN, str, 1); SetPlayerPos(playerid, PlayerInfo[playerid][pAx], PlayerInfo[playerid][pAy], PlayerInfo[playerid][pAz]); helprequested[p] = 0; helprequestid[p] = 0; return 1; } return 1; } CMD:hrs(playerid, params[]) { if(PlayerInfo[playerid][pModerator] <= 1 && PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command yet!"); // if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command yet!"); SendClientMessage(playerid, COLOR_GREEN, "|____________________Help Request________________________|"); for(new x; x<MAX_PLAYERS; x++) { if(helprequested[x] == 1) { SendClientMessage(playerid, COLOR_LIGHTRED, helprequesttext[x]); } } SendClientMessage(playerid, COLOR_GREEN, "|___________________________________________________|"); // ShowPlayerDialog(playerid, DIALOG_HELPREQUESTS, DIALOG_STYLE_MSGBOX, "Help Requests", HRInfo, "Close", ""); return 1; }