playername - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: playername (
/showthread.php?tid=264230)
playername -
bartje01 - 25.06.2011
Hey guys. When I use a message in a string where my name should be displayed in and there are more players online it's very buggy.
Instead of:
Welcome bartje01 it says welcome artje01
I use it like this:
on top:
pawn Код:
new Name[MAX_PLAYER_NAME]
onplayerconnect
pawn Код:
GetPlayerName(playerid, Name, sizeof(Name));
format(String,sizeof(String),"Welcome to {FF0000}Infinity Roleplay {00FF00}%s",Name[playerid]);
SendClientMessage(playerid,COLOR_GREEN,String);
What is wrong?
Thanks
Re: playername -
||123|| - 25.06.2011
Remove [playerid] from Name
Re: playername -
bartje01 - 25.06.2011
Ok ty that worked. But how will I do it here?
I don't want to use GetPlayerName everywhere.
pawn Код:
COMMAND:makeadmin(playerid,params[])
{
new level,id;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_GREY,"You're not an Infinity RCON admin, you're not allowed to use this.");
if(sscanf(params,"ud",id,level)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /makeadmin [playerid] [level]");
format(String,sizeof(String),"%s made you a admin level %d",Name[playerid],level);
SendClientMessage(id,COLOR_ORANGE,String);
format(String,sizeof(String),"You've made %s admin level %d",Name[id],level);
SendClientMessage(playerid,COLOR_ORANGE,String);
PlayerInfo[id][pAdminLevel] = level;
return 1;
}
Re: playername -
iPLEOMAX - 25.06.2011
This..?
Add this to the end of your script. Then use it everytime whenever a player's name is required.
pawn Код:
stock GetName(playerid)
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername,sizeof(playername));
return playername;
}
So, whenever you format a string, just add GetName(id).. No need for GetPlayerName again & again..
pawn Код:
format(String,sizeof(String),"%s made you a admin level %d",GetName(playerid),level);
Re: playername -
bartje01 - 25.06.2011
Oooh I see. Thanks