!IsPlayerConnected is not working
#1

Hi. When I type this command for an inactive player, I'm getting slap by myself. And When I do it for an active player, he is getting slap by me so its ok. But I don't know why !IsPlayerConnected isn't working, any idea about this ?

Code:
dcmd_slap(playerid,params[])
{
	if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid,COLOR_WHITE,"SERVER: Unknown command.");
	new targetid;
	if(sscanf(params, "uz", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFFF}[{FF0000}USAGE{FFFFFF}]{EFF7FF} /slap <playerid>");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFFF}[{FF0000}ERROR{FFFFFF}]{EFF7FF} Inactive player.");
	else
	{
	new Float:SLX, Float:SLY, Float:SLZ;
	GetPlayerPos(targetid, SLX, SLY, SLZ);
	SetPlayerPos(targetid, SLX, SLY, SLZ+10);
  	}
	return 1;
}
Reply
#2

Quote:

if(sscanf(params, "uz", targetid))

You're asking for 2 input's and you've only defined 1.
Reply
#3

pawn Code:
if(sscanf(params, "uz", targetid))
uz? just use "u"

pawn Code:
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid,COLOR_WHITE,"SERVER: Unknown command.");
you can simply use this
pawn Code:
if(PlayerInfo[playerid][pAdmin] == 0) return 0;
Reply
#4

Quote:
Originally Posted by emokidx111
View Post
pawn Code:
if(sscanf(params, "uz", targetid))
uz? just use "u"

pawn Code:
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid,COLOR_WHITE,"SERVER: Unknown command.");
you can simply use this
pawn Code:
if(PlayerInfo[playerid][pAdmin] == 0) return 0;
Thanks for this.
Code:
if(PlayerInfo[playerid][pAdmin] == 0) return 0;
And I did "u" now but same problem, slapping myself if I write inactive playerid.
Reply
#5

all i can think of is adding this before Setting the players position.
pawn Code:
new name[128];
GetPlayerName(targetid, name, sizeof(name));
Reply
#6

pawn Code:
dcmd_slap( playerid, params[ ] )
{
    if( PlayerInfo[ playerid ][ pAdmin ] == 0 ) return SendClientMessage( playerid,COLOR_WHITE,"SERVER: Unknown command." );
    new targetid;
    if( sscanf( params, "r", targetid ) ) return SendClientMessage( playerid, COLOR_WHITE, "{FFFFFF}[{FF0000}USAGE{FFFFFF}]{EFF7FF} /slap <playerid>" );
    if( targetid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, COLOR_WHITE, "{FFFFFF}[{FF0000}ERROR{FFFFFF}]{EFF7FF} Inactive player." );
    new Float:SLX, Float:SLY, Float:SLZ;
    GetPlayerPos( targetid, SLX, SLY, SLZ );
    SetPlayerPos( targetid, SLX, SLY, SLZ + 10 );
    return 1;
}
Reply
#7

Quote:
Originally Posted by Dwane
View Post
pawn Code:
dcmd_slap( playerid, params[ ] )
{
    if( PlayerInfo[ playerid ][ pAdmin ] == 0 ) return SendClientMessage( playerid,COLOR_WHITE,"SERVER: Unknown command." );
    new targetid;
    if( sscanf( params, "r", targetid ) ) return SendClientMessage( playerid, COLOR_WHITE, "{FFFFFF}[{FF0000}USAGE{FFFFFF}]{EFF7FF} /slap <playerid>" );
    if( targetid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, COLOR_WHITE, "{FFFFFF}[{FF0000}ERROR{FFFFFF}]{EFF7FF} Inactive player." );
    new Float:SLX, Float:SLY, Float:SLZ;
    GetPlayerPos( targetid, SLX, SLY, SLZ );
    SetPlayerPos( targetid, SLX, SLY, SLZ + 10 );
    return 1;
}
Still slapping my self if it inactive player.
Reply
#8

Quote:
Originally Posted by Matz
View Post
Still slapping my self if it inactive player.
Use sscanf plugin, not the pawno version.

Try this:
Code:
dcmd_slap( playerid, params[ ] )
{
	if( PlayerInfo[ playerid ][ pAdmin ] == 0 )
		return 0;
	
	new targetid = -1;
	if( sscanf( params, "u", targetid ) ) 
		return SendClientMessage( playerid, COLOR_WHITE, "[{FF0000}USAGE{FFFFFF}]{EFF7FF} /slap <playerid>" );

	if( !IsPlayerConnected( targetid ) )
		return SendClientMessage( playerid, COLOR_WHITE, "[{FF0000}USAGE{FFFFFF}]{EFF7FF} /slap <playerid>" );

	new Float:SLX, Float:SLY, Float:SLZ;
	GetPlayerPos( targetid, SLX, SLY, SLZ );
	SetPlayerPos( targetid, SLX, SLY, SLZ + 10 );
	return 1;
}
Reply
#9

Quote:
Originally Posted by costel_nistor96
View Post
Use sscanf plugin, not the pawno version.

Try this:
Code:
dcmd_slap( playerid, params[ ] )
{
	if( PlayerInfo[ playerid ][ pAdmin ] == 0 )
		return 0;
	
	new targetid = -1;
	if( sscanf( params, "u", targetid ) ) 
		return SendClientMessage( playerid, COLOR_WHITE, "[{FF0000}USAGE{FFFFFF}]{EFF7FF} /slap <playerid>" );

	if( !IsPlayerConnected( targetid ) )
		return SendClientMessage( playerid, COLOR_WHITE, "[{FF0000}USAGE{FFFFFF}]{EFF7FF} /slap <playerid>" );

	new Float:SLX, Float:SLY, Float:SLZ;
	GetPlayerPos( targetid, SLX, SLY, SLZ );
	SetPlayerPos( targetid, SLX, SLY, SLZ + 10 );
	return 1;
}
I'm using plugin version already. And still slapping myself. What kind of problem is this :/
Reply
#10

Quote:
Originally Posted by Matz
View Post
I'm using plugin version already. And still slapping myself. What kind of problem is this :/
Maybe sscanf don't work very good with DCMD, try to change DCMD with ZCMD, it's faster, easier and is not hard to change.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)