SA-MP Forums Archive
!IsPlayerConnected is not working - 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: !IsPlayerConnected is not working (/showthread.php?tid=319266)



!IsPlayerConnected is not working - Matz - 18.02.2012

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;
}



Re: !IsPlayerConnected is not working - WackoX - 18.02.2012

Quote:

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

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


Re: !IsPlayerConnected is not working - emokidx - 18.02.2012

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;



Re: !IsPlayerConnected is not working - Matz - 18.02.2012

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.


Re: !IsPlayerConnected is not working - emokidx - 18.02.2012

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



Re: !IsPlayerConnected is not working - Konstantinos - 18.02.2012

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;
}



Re: !IsPlayerConnected is not working - Matz - 18.02.2012

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.


Re: !IsPlayerConnected is not working - IstuntmanI - 18.02.2012

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;
}



Re: !IsPlayerConnected is not working - Matz - 18.02.2012

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 :/


Re: !IsPlayerConnected is not working - IstuntmanI - 18.02.2012

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.