Setting a command to a certain Player?
#1

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

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;
}
Reply
#3

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

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

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;
}
Reply
#6

Edit Removed: dont want a warning just use the above anyway.
Reply
#7

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?
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)