SA-MP Forums Archive
/requesthelp bugged - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /requesthelp bugged (/showthread.php?tid=482765)



/requesthelp bugged - Blademaster680 - 22.12.2013

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:

Код:
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;
}
I would also like it so when someone finishes the helprequest it resets the "RID" so the next person to /requesthelp gets the "RID'


Re: /requesthelp bugged - CutX - 22.12.2013

in /accepthr

PHP код:
CMD:accepthr(playeridparams[])
{
    new 
rid;
    new 
Float:xFloat:yFloat:z;
    if(
PlayerInfo[playerid][pModerator] <= 1) return SendClientMessage(playeridCOLOR_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(str2sizeof(str2), "%s has accepted the help request [RID: %d]"GetName(playerid), rid);
            
SendClientMessageToModeratorsEx(COLOR_CYANstr21);
            
helprequested[p] = 0;
            
helprequestid[p] = 0;
            
GetPlayerPos(playeridPlayerInfo[playerid][pAx], PlayerInfo[playerid][pAy], PlayerInfo[playerid][pAz]);
            
            
GetPlayerPos(pxyz);
            
SetPlayerPos(playeridx+1y+1z);
            
            
SetTimerEx("HelpRequest"1000false"d"playerid);
            
            return 
1;
        }
        else
        {
            if(
success == 0SendClientMessage(playerid, -1"That is not a valid report!");
            return 
1;
        }
    }
    return 
1;

rid is your param for the playerid correct?

so, you and your brother, lets say ypu connected first, then you're ID 0 and your bro is ID 1
now, if your bro wants to accept the request, he types "/accepthr 0"
but oh, what's this code after if(sscanf(.... ?
if(rid == 0) return SendClientMessage(playerid, -1, "Invalid Report ID. Use the report ID - Not the playerid / name.");
there you go. That's why it's always sayin this ^^

//EDIT: figured you mean report id by rid, but either way, if your bro enters 0, you got the same problem.
that's the only thing which triggers that message


Re: /requesthelp bugged - Blademaster680 - 22.12.2013

I dont really understand what you mean... The one time he logged in and his ID was 0 and mine was 1 and I /requesthelp which made the "RID 1" so he type /accepthr 1 but it still said "invalid report ID"


Re: /requesthelp bugged - CutX - 22.12.2013

Quote:
Originally Posted by Blademaster680
Посмотреть сообщение
I dont really understand what you mean... The one time he logged in and his ID was 0 and mine was 1 and I /requesthelp which made the "RID 1" so he type /accepthr 1 but it still said "invalid report ID"
impossible,
test it again with your bro.

this
if(rid == 0) return SendClientMessage(playerid, -1, "Invalid Report ID. Use the report ID - Not the playerid / name.");
can ONLY get called when rid equals 0. and that only happens when you type "/accepthr 0"
maybe there was some misunderstanding with your bro, try it again please.

Code always does exactly what it's been told, not like humans, remember that


Re: /requesthelp bugged - Blademaster680 - 22.12.2013

Ok so now the accepthr is fixed but now when I say /finishhr it doesnt do anything, Its suppose to teleport me back and such but it doesnt


Re: /requesthelp bugged - CutX - 23.12.2013

you have to store the coords in accepthr:
PHP код:
//global var
new Float:hrP[MAX_PLAYERS][3];
//in your accepthhr: (before you teleport the player)
GetPlayerPos(playerid,hrP[playerid][0], hrP[playerid][1], hrP[playerid][2]);
//in finishr:
SetPlayerPos(playerid,hrP[playerid][0], hrP[playerid][1], hrP[playerid][2]); 



Re: /requesthelp bugged - Blademaster680 - 24.12.2013

No it still doesnt want todo anything . We use /finishhr but it still doesnt want todo anything. It doesnt say "You are not authorized", nor does it teleport and say he has finished the hr.
Any help?