Quote:
Originally Posted by martin3644
Thank you for help, but I dont understand this. I'm noob in scripting 
|
Well okay, let me give you an example.
The command would look something like this (using zcmd and sscanf2):
pawn Код:
CMD:astatus(playerid, params[])
{
new
szPrefix[ 10 ] //I chose 9 letters as maximum (7 inside [ ])
;
if( sscanf( params, "s[10]", szPrefix ))
return SendClientMessage( playerid, 0x00FF00FF, "[USAGE] /astatus (prefix)" );
new
szName[ MAX_PLAYER_NAME ]
;
GetPlayerName( playerid, szName, MAX_PLAYER_NAME );
format( szPrefix, sizeof( szPrefix ), "[%s]", szPrefix ); //put it in square brackets
strins( szName, szPrefix, 0 ); //this would insert the parameter (prefix) at the beginning of the name string
SetPlayerName( playerid, szName ); //change the name to the newly updated string with the prefix.
return true;
}
To add random prefix you would simply need to put a global string array, like so:
pawn Код:
new
g_szPrefixes[][] =
{
"Prefix1",
"Prefix2
}
;
And so on.
If you'd want the player to get a random prefix when no parameters were written, you could simply alter the command to something like this:
pawn Код:
CMD:astatus(playerid, params[])
{
new
szPrefix[ 10 ] //I chose 9 letters as maximum (7 inside [ ])
;
sscanf( params, "S[10]", szPrefix ));
new
szName[ MAX_PLAYER_NAME ]
;
GetPlayerName( playerid, szName, MAX_PLAYER_NAME );
if( isnull( szPrefix ))
{
new
iRand = random( sizeof( g_szPrefixes ))
;
strcat( szPrefix, g_szPrefixes[ iRand ] );
}
format( szPrefix, sizeof( szPrefix ), "[%s]", szPrefix ); //put it in square brackets
strins( szName, szPrefix, 0 ); //this would insert the parameter (prefix) at the beginning of the name string
SetPlayerName( playerid, szName ); //change the name to the newly updated string with the prefix.
return true;
}
To get the /astatusoff thing to work, you could declare a global string array to hold the player's original name on connect, then just set the players name back to that array whenever a player did /astatusoff. Example:
pawn Код:
CMD:astatusoff(playerid, params[])
{
SetPlayerName( playerid, g_szMyGlobalNameVariable[ playerid ] ); //change the name to the newly updated string with the prefix.
return true;
}
I hope you understand a little bit more! If you don't, then I'm sorry - I can't explain it more noobfriendly.