Posts: 22
Threads: 7
Joined: Mar 2011
Reputation:
0
Hello,
Please I need a peice of code (and how-to) create a global varaiable (a string that will work in all the publics) that will get the player name.
Thanks you all.
Posts: 271
Threads: 15
Joined: May 2011
Reputation:
0
don't double post! :P
use edit
btw idk how to global variable >>edit
Posts: 22
Threads: 7
Joined: Mar 2011
Reputation:
0
Stop being troll, I really want to know how to define a global string varaiable.
Posts: 271
Threads: 15
Joined: May 2011
Reputation:
0
if im troll wait until ppl help you! NEW SLAUGHTER!
Posts: 22
Threads: 7
Joined: Mar 2011
Reputation:
0
I just want a global varaiable to store the name of the player in this. because in some cases in my script the real nickname of the player should be changed.
So I need a way to store the player name in a global varaiable.
Anyone?
Posts: 1,046
Threads: 29
Joined: Mar 2010
Use
pawn Код:
SetPVarString(playerid, str[], string_return, len);
to store strings into player variables.
Example:
pawn Код:
public OnPlayerConnect(playerid)
{
pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
SetPVarString(playerid, "RealName", pname); //Here we'll store the real nick name into a pvar.
return 1;
}
//Somewhere in your script you can change his/her name without changing our player variable
//After this we can use the player variable on any prints (Example: A SendClientMessageToAll func in OnPlayerDisconnect)
public OnPlayerDisconnect(playerid, reason)
{
new pname[MAX_PLAYER_NAME], str[128];
GetPVarString(playerid, "RealName", pname, sizeof(pname)); //here we'll get the real nick name from pvar.
format(str, sizeof(str), "%d %s has left the server.", playerid, pname);
SendClientMessageToAll(0x999999, str);
return 1;
}