GetPlayerName help
#1

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

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

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

there is already "new name" remove it

ex.

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

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[...];
Reply
#6

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

wow tnx for helping

I gave 100 rep - 99 reps both of you
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)