SA-MP Forums Archive
GetPlayerName help - 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: GetPlayerName help (/showthread.php?tid=340975)



GetPlayerName help - MichaelProPlayer - 09.05.2012

I wanna create this type of script:

when player spawned if he's name is Michael then a client message will be send ..

I dont know how to script that plz can someone help me ?


Re: GetPlayerName help - [MG]Dimi - 09.05.2012

Like this:
pawn Код:
#include <a_samp>

public OnPlayerSpawn(playerid)
{
    new name[24];
    GetPlayerName(playerid,name,24);
    if(!strcmp(name,"Michael",false)) SendClientMessageToAll(0x00FF00FF,"Michael has spawned!");
    return 1;
}



Re: GetPlayerName help - MichaelProPlayer - 09.05.2012

Sry I get his error
Код:
F:\PROGRA~1\ROCKST~1\GTASAN~1\SAMP03~2\GAMEMO~1\CNR.pwn(2525) : warning 219: local variable "name" shadows a variable at a preceding level



Re: GetPlayerName help - JaKe Elite - 09.05.2012

there is already "new name" remove it

ex.

pawn Код:
new name[24]; //remove this
new name[MAX_PLAYER_NAME];



Re: GetPlayerName help - [MG]Dimi - 09.05.2012

pawn Код:
public OnPlayerSpawn(playerid)
{
    GetPlayerName(playerid,name,24);
    if(!strcmp(name,"Michael",false)) SendClientMessageToAll(0x00FF00FF,"Michael has spawned!");
    return 1;
}
You already have
pawn Код:
new name[...];



Re: GetPlayerName help - [ABK]Antonio - 09.05.2012

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
Like this:
pawn Код:
#include <a_samp>

public OnPlayerSpawn(playerid)
{
    new name[24];
    GetPlayerName(playerid,name,24);
    if(!strcmp(name,"Michael",false)) SendClientMessageToAll(0x00FF00FF,"Michael has spawned!");
    return 1;
}
I wouldn't use 24 but MAX_PLAYER_NAME instead...

pawn Код:
new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name));
SAMP's name length could always change...then you'd be the one going through all of your new name[24] (unless using a stock) changing them to the new size..


Re: GetPlayerName help - MichaelProPlayer - 09.05.2012

wow tnx for helping

I gave 100 rep - 99 reps both of you