SA-MP Forums Archive
Specific names - 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: Specific names (/showthread.php?tid=466016)



Specific names - Fernado Samuel - 25.09.2013

Hello.
I want to make a command /sethealth (i know the functions to make that command).

I want to make it like using that cmd by a specified name to a specified name.
For example Fernado is using the command to Samuel, got it? No others can use that command.
Is it possible?


Re: Specific names - Konstantinos - 25.09.2013

pawn Код:
CMD:sethealth( playerid, params[ ] )
{
    new
        id,
        Float: health
    ;
    if( sscanf( params, "rf", id, health ) ) return SendClientMessage( playerid, -1, "Usage: /sethealth <ID/Part Of Name> <health>" );
    if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Offline player" );

    new
        _name[ MAX_PLAYER_NAME ]
    ;
    GetPlayerName( playerid, _name, MAX_PLAYER_NAME );
    if( !strcmp( _name, "Fernado_Samuel", true ) ) SetPlayerHealth( id, health );
    else SendClientMessage( playerid, -1, "Only Fernado_Samuel can use this command!" );
    return 1;
}



Re: Specific names - [HK]Ryder[AN] - 25.09.2013

GetPlayerName and then check if the name is "Samuel"


Re: Specific names - Fernado Samuel - 25.09.2013

Quote:
Originally Posted by [HK]Ryder[AN]
Посмотреть сообщение
GetPlayerName and then check if the name is "Samuel"
Can you show me the code please? As Konstantinos shows, in that code fernado can only use that command but it should work only to Samuel.


Re: Specific names - Konstantinos - 25.09.2013

Doing the same thing. Getting the name from the player the playerid typed and check it with strcmp (Remember, if it returns 0 - both strings (names) are same).

pawn Код:
CMD:sethealth( playerid, params[ ] )
{
    new
        id,
        Float: health
    ;
    if( sscanf( params, "rf", id, health ) ) return SendClientMessage( playerid, -1, "Usage: /sethealth <ID/Part Of Name> <health>" );
    if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Offline player" );

    new
        _name[ MAX_PLAYER_NAME ]
    ;
    GetPlayerName( playerid, _name, MAX_PLAYER_NAME );
    if( !strcmp( _name, "Fernado", true ) )
    {
        GetPlayerName( id, _name, MAX_PLAYER_NAME );
        if( !strcmp( _name, "Samuel", true ) ) SetPlayerHealth( id, health );
        else SendClientMessage( playerid, -1, "You can use this command only to Samuel!" );
    }
    else SendClientMessage( playerid, -1, "Only Fernado can use this command!" );
    return 1;
}