Paste ID into Name - 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: Paste ID into Name (
/showthread.php?tid=90179)
Paste ID into Name -
DeathOnaStick - 06.08.2009
Hey Community...
Here i go again with another question:
Today i just tried to paste the Id of the Player into his name, and used this code:
Код:
public OnPlayerSpawn(playerid)
{
new CurrentName[MAX_PLAYER_NAME];
new CurrentID;
new NewName[128];
GetPlayerName(playerid,CurrentName,sizeof(CurrentName));
CurrentID = GetPlayerID("CurrentName");
format(NewName,sizeof(NewName),"%s[%i]",CurrentName,CurrentID);
SetPlayerName(playerid,NewName);
return 1;
}
It doesnt give me Errors or warnings, but the problem is, that it doesnt work :/
Pls tell me what i did wrong!
Greetings from Germany,
DeathOnaStick
Re: Paste ID into Name -
JaTochNietDan - 06.08.2009
Why do you need GetPlayerID? It's already stored in "playerid"
By the way, its not working because you put "CurrentName" in quotes, which makes it a string, its searching for "CurrentName" and not the name thats defined in the variable, just change it to:
GetPlayerID(CurrentName);
Also, you don't need to do that anyway, just add playerid to the end of the format instead of CurrentID
Re: Paste ID into Name -
DeathOnaStick - 06.08.2009
Because i needed to use it in format.... didnt know how to do it another way =D... Seemed to be the easiest way for me
Re: Paste ID into Name -
kaisersouse - 06.08.2009
Quote:
Originally Posted by DeathOnaStick
Because i needed to use it in format.... didnt know how to do it another way =D... Seemed to be the easiest way for me 
|
just replace CurrentID with playerid in the format function
Re: Paste ID into Name -
DeathOnaStick - 06.08.2009
Thanks very much, it worked, but can you tell me actually WHY it didnt work? XD
Re: Paste ID into Name -
JaTochNietDan - 06.08.2009
Quote:
Originally Posted by DeathOnaStick
Thanks very much, it worked, but can you tell me actually WHY it didnt work? XD
|
I've explained why it didn't work in my post
Re: Paste ID into Name -
DeathOnaStick - 06.08.2009
lol sry didnt see :/
btw... thanks very much =D
Re: Paste ID into Name -
kaisersouse - 06.08.2009
i use this on everystuff. ill post the code in a second (will add to this post)
In OnPlayerText:
Код:
new textmsg[128];
format(textmsg,sizeof(textmsg),"[%d] %s", playerid,text);
SendPlayerMessageToAll(playerid, textmsg);
return 0;