I need some help. (Checking if the playerid is equal to the targetid)
#1

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.
Reply
#2

Change

if(playerid == targetid)

to

if(targetid == playerid)
Reply
#3

Still doing the same thing.
Reply
#4

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!");
Reply
#5

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

REP +
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)