Setting a command to a certain Player? -
Swizzzy - 13.09.2011
Well the title basically says it all, I need to know how to set a command towards a Certain player, And A Certain Class for the player, If the player is not "The Player", Then he'll be killed, Something like that..
If anyone could possibly tell me, or post a code for me, It was be great thank you..
Re: Setting a command to a certain Player? -
admantis - 13.09.2011
A basic example of command restriction to a specific player.
pawn Код:
CMD:command( playerid, params[] ) // when someone types /command
{
new szName[ 24 ];
GetPlayerName( playerid, szName, 24);
if ( strcmp ( szName, "Swizzzy", true ) == 0) // you can change "Swizzzy" to another name
{
// do the command actions
}
else
{
return SendClientMessage( playerid, -1, "you are not allowed to perform this command");
}
return true;
}
Re: Setting a command to a certain Player? -
Kush - 13.09.2011
Quote:
Originally Posted by Swizzzy
Well the title basically says it all, I need to know how to set a command towards a Certain player, And A Certain Class for the player, If the player is not "The Player", Then he'll be killed, Something like that..
If anyone could possibly tell me, or post a code for me, It was be great thank you..
|
Elaborate.
Re: Setting a command to a certain Player? -
Swizzzy - 13.09.2011
Quote:
Originally Posted by admantis
A basic example of command restriction to a specific player.
pawn Код:
CMD:command( playerid, params[] ) // when someone types /command { new szName[ 24 ]; GetPlayerName( playerid, szName, 24); if ( strcmp ( szName, "Swizzzy", true ) == 0) // you can change "Swizzzy" to another name { // do the command actions } else { return SendClientMessage( playerid, -1, "you are not allowed to perform this command"); } return true; }
|
Errors
Код:
C:\Users\Parent\Desktop\Everything\Test Server\gamemodes\ESGDM.pwn(737) : warning 203: symbol is never used: "command"
Re: Setting a command to a certain Player? -
admantis - 13.09.2011
Quote:
Originally Posted by Swizzzy
Errors
Код:
C:\Users\Parent\Desktop\Everything\Test Server\gamemodes\ESGDM.pwn(737) : warning 203: symbol is never used: "command"
|
I believe you put it inside a callback, or don't have ZCMD. If you want a strcmp command use this:
pawn Код:
if ( strcmp( cmdtext, "/command", true) == 0) // when someone types /command
{
new szName[ 24 ];
GetPlayerName( playerid, szName, 24);
if ( strcmp ( szName, "Swizzzy", true ) == 0) // you can change "Swizzzy" to another name
{
// do the command actions
}
else
{
return SendClientMessage( playerid, -1, "you are not allowed to perform this command");
}
return true;
}
Re: Setting a command to a certain Player? -
IceCube! - 13.09.2011
Edit Removed: dont want a warning just use the above anyway.
Re: Setting a command to a certain Player? -
Swizzzy - 13.09.2011
Quote:
Originally Posted by admantis
I believe you put it inside a callback, or don't have ZCMD. If you want a strcmp command use this:
pawn Код:
if ( strcmp( cmdtext, "/command", true) == 0) // when someone types /command { new szName[ 24 ]; GetPlayerName( playerid, szName, 24); if ( strcmp ( szName, "Swizzzy", true ) == 0) // you can change "Swizzzy" to another name { // do the command actions } else { return SendClientMessage( playerid, -1, "you are not allowed to perform this command"); } return true; }
|
Worked, thank you, But how do i set a certain Class to a Certain player?
Re: Setting a command to a certain Player? -
admantis - 13.09.2011
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
new szName[ 24 ];
GetPlayerName( playerid, szName, 24 );
if ( GetPlayerSkin ( playerid ) == /*skin you want*/ )
{
if ( strcmp ( szName, "Swizzzy", true ) == 0 )
{
SendClientMessage( playerid, 0xffffffff, "permisson for this skin granted!");
}
else
{
SendClientMessage( playerid, 0xffffffff, "only swizzzy can use this skin");
return 0; /* return 0 means he won't spawn */
}
}
return 1;
}