Get Player Name? Or? -
Quest123 - 30.08.2010
Well i'm scripting in a simple teleport, but i've got a problem.
When the player teleports to the position given in the script, i want it to send a message to all the people in the server.
So this is what i've done:
Код:
if(strcmp(cmd, "/lsairport", true) == 0) {
SetPlayerPos(playerid,1984.3177,-2473.2759,13.5469);
SendClientMessage(playerid, COLOR_BRIGHTRED,"Welcome to Los Santos Airport!");
SendClientMessageToAll(COLOR_PINK,"%d Has Teleport To LS Airport!");
return 1;
}
As you can see i used '%d' just hoping it would give the players name, but no... didn't work like that, so now when ever i type it this comes up:
Anyone know what i need to do/add to that script so the players name will show up instead of all those numbers?
Thanks
Re: Get Player Name? Or? -
[XST]O_x - 30.08.2010
pawn Код:
new string[64];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
format(string,sizeof(string),"%s has teleported to LS Airport!",pName);
SendClientMessageToAll(COLOR_PINK,string);
Re: Get Player Name? Or? -
Bumbis - 30.08.2010
pawn Код:
if(strcmp(cmd, "/lsairport", true) == 0)
{
new name[MAX_PLAYER_NAME];
new string[128];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string), "%s Has Teleport To LS Airport!",name);
SetPlayerPos(playerid,1984.3177,-2473.2759,13.5469);
SendClientMessage(playerid, COLOR_BRIGHTRED,"Welcome to Los Santos Airport!");
SendClientMessageToAll(COLOR_PINK,string);
return 1;
}
Re: Get Player Name? Or? -
Retardedwolf - 30.08.2010
Edited. Top posters will already help the thread starter.
Re: Get Player Name? Or? -
Quest123 - 30.08.2010
Thanks guys, but when ever i try to complie, i get this warning:
Код:
C:\Users\azd\Desktop\samp03bsvr_R2_win32\gamemodes\Fruity10.pwn(251) : warning 219: local variable "string" shadows a variable at a preceding level
Re: Get Player Name? Or? -
Retardedwolf - 30.08.2010
Quote:
Originally Posted by Quest123
Thanks guys, but when ever i try to complie, i get this warning:
Код:
C:\Users\azd\Desktop\samp03bsvr_R2_win32\gamemodes\Fruity10.pwn(251) : warning 219: local variable "string" shadows a variable at a preceding level
|
remove "
" and just use it as you already did that.
Re: Get Player Name? Or? -
Bumbis - 30.08.2010
if(strcmp(cmd, "/lsairport", true) == 0)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string), "%s Has Teleport To LS Airport!",name);
SetPlayerPos(playerid,1984.3177,-2473.2759,13.5469);
SendClientMessage(playerid, COLOR_BRIGHTRED,"Welcome to Los Santos Airport!");
SendClientMessageToAll(COLOR_PINK,string);
return 1;
}
Just delete new string[128];
Re: Get Player Name? Or? -
Quest123 - 30.08.2010
Thanks guys for all your help, all working now.