SA-MP Forums Archive
I need some help. (Checking if the playerid is equal to the targetid) - 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: I need some help. (Checking if the playerid is equal to the targetid) (/showthread.php?tid=580982)



I need some help. (Checking if the playerid is equal to the targetid) - Th3UnKnOwN - 09.07.2015

Alright. The issue is either in if(!IsPlayerConnected(targetid)) or in if(playerid == targetid). The reason I believe it to be one of these 2, is showed in the video below.

VIDEO:Forcecmds command bug.


The command:
Код:
CMD:forcecmds(playerid, params[])
{
	new targetid, string[200];
	if(!IsPlayerAdmin(playerid)) return 0;
	if(IsPlayerAdmin(playerid))
	{
		if(sscanf(params, "u", targetid)) return SendMessage(playerid, COLOR_RED, "USAGE: /forcecmds <playerid>");
		if(!IsPlayerConnected(targetid)) return SendMessage(playerid, COLOR_RED, "ERROR: No one with that ID is connected to the server.");
		if(playerid == targetid) return SendMessage(playerid, COLOR_RED, "You can't use this command on yourself.");
		ShowPlayerCmds(targetid);
	}
	format(string, sizeof(string), "Admin %s(%d) Has shown you all available commands.", PlayerName(playerid), playerid);
	SendMessage(targetid, COLOR_LIME, string);
	return 1;
}
It compiles just fine. No issues there, but it doesn't appear to be checking if(!IsPlayerConnected(targetid)) and if(playerid == targetid) appears to be bugged, because no matter what ID you put. It will always return as your ID.


Re: I need some help. (Checking if the playerid is equal to the targetid) - Stev - 09.07.2015

Change

if(playerid == targetid)

to

if(targetid == playerid)


Re: I need some help. (Checking if the playerid is equal to the targetid) - Th3UnKnOwN - 09.07.2015

Still doing the same thing.


Re: I need some help. (Checking if the playerid is equal to the targetid) - Sime30 - 09.07.2015

I would update my sscanf.
Here, I uploaded on my dropbox

https://www.dropbox.com/s/wq5jihl0my...canf2.inc?dl=0

https://www.dropbox.com/s/kejoprt25b...scanf.dll?dl=0

Edit: Also, you don't need IsPlayerConnected, only use this

pawn Код:
if(targetid== INVALID_PLAYER_ID)return SendMessage(playerid,-1,"Wrong ID!");



Re: I need some help. (Checking if the playerid is equal to the targetid) - Th3UnKnOwN - 09.07.2015

Thank you for the updated sscanf files. That was the issue. It was always returning ID 0.

REP +