SA-MP Forums Archive
NEED HELP With VARAIABLE - Global - 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: NEED HELP With VARAIABLE - Global (/showthread.php?tid=268161)



NEED HELP With VARAIABLE - Global - Micheal_ - 11.07.2011

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.


Re: NEED HELP With VARAIABLE - Global - Micheal_ - 11.07.2011

UP. Help...?


Re: NEED HELP With VARAIABLE - Global - [GTA]AmericanGangster - 11.07.2011

don't double post! :P

use edit

btw idk how to global variable >>edit


Re: NEED HELP With VARAIABLE - Global - Micheal_ - 11.07.2011

Stop being troll, I really want to know how to define a global string varaiable.


Re: NEED HELP With VARAIABLE - Global - [GTA]AmericanGangster - 11.07.2011

if im troll wait until ppl help you! NEW SLAUGHTER!


Re: NEED HELP With VARAIABLE - Global - Adil - 11.07.2011

pawn Код:
new string[128];
on top of gamemode.

Quote:
Originally Posted by TAGproduction
Посмотреть сообщение
if im troll wait until ppl help you! NEW SLAUGHTER!
Don't spam, or you'll get banned.


Re: NEED HELP With VARAIABLE - Global - Micheal_ - 11.07.2011

Got error.


I did:
Quote:

new string[128];

Quote:

public OnPlayerConnect(playerid)
{ string = GetPlayerName(playerid);

ERROR & Warnings:
Quote:

(82) : error 017: undefined symbol "string"
(82) : warning 202: number of arguments does not match definition
(82) : warning 202: number of arguments does not match definition




Re: NEED HELP With VARAIABLE - Global - Adil - 11.07.2011

pawn Код:
public OnPlayerConnect(playerid)
{
    GetPlayerName(playerid, string, sizeof(string));
    return 1;
}



Re: NEED HELP With VARAIABLE - Global - Micheal_ - 11.07.2011

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?



Re: NEED HELP With VARAIABLE - Global - BigETI - 11.07.2011

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;
}