Help with command - 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: Help with command (
/showthread.php?tid=319623)
Help with command -
boyan96 - 19.02.2012
How i can make this command can you it from one user (maybe it will need his nickname in the server)
PHP код:
if(strcmp(cmd, "/boxevent", true) == 0)
{
if(IsPlayerConnected(playerid) && (boxevent == 0))
{
boxevent = 1;
BroadCast(COLOR_WHITE, " write(/joinboxevent)!");
}
else if(IsPlayerConnected(playerid) && (boxevent == 1))
{
boxevent = 0;
BroadCast(COLOR_GREEN, " deactive.");
}
return 1;
}
Re: Help with command -
aRoach - 19.02.2012
Function:
pawn Код:
Name( playerid )
{
new s_p_N[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, s_p_N, sizeof s_p_N );
return( s_p_N );
}
Command:
pawn Код:
if(strcmp(cmd, "/boxevent", true) == 0)
{
if( !strcmp( Name( playerid ), "NAME", false ) )
{
if( boxevent == 0 )
{
boxevent = 1;
BroadCast( COLOR_WHITE, " write(/joinboxevent)!" );
}
else
{
boxevent = 0;
BroadCast( COLOR_GREEN, " deactive." );
}
}
return 1;
}
PS: Is Case-Sensitive
Re: Help with command -
boyan96 - 19.02.2012
Can you make it for two nicknames
Re: Help with command -
aRoach - 19.02.2012
Quote:
Originally Posted by boyan96
Can you make it for two nicknames
|
Yes:
pawn Код:
if(strcmp(cmd, "/boxevent", true) == 0)
{
if( !strcmp( Name( playerid ), "NAME", false ) || !strcmp( Name( playerid ), "NAME2", false ) )
{
if( boxevent == 0 )
{
boxevent = 1;
BroadCast( COLOR_WHITE, " write(/joinboxevent)!" );
}
else
{
boxevent = 0;
BroadCast( COLOR_GREEN, " deactive." );
}
}
return 1;
}
PS: Still Case-Sensitive !
Re: Help with command -
Twisted_Insane - 19.02.2012
pawn Код:
if(strcmp(cmd, "/boxevent", true) == 0)
{
if( !strcmp( Name( playerid ), "NAME", false ) )
{
if( boxevent == 0 )
{
boxevent = 1;
BroadCast( COLOR_WHITE, " write(/joinboxevent)!" );
}
else if ( !strcmp( Name( playerid ), "NAME2", false ) )
if( boxevent == 0 )
{
boxevent = 1;
BroadCast( COLOR_WHITE, " write(/joinboxevent)!" );
}
else
{
boxevent = 0;
BroadCast( COLOR_GREEN, " deactive." );
}
}
}
Re: Help with command -
Konstantinos - 19.02.2012
@Twisted_Insane
The else if is outside the first if statement.