NEED HELP With VARAIABLE - Global
#1

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.
Reply
#2

UP. Help...?
Reply
#3

don't double post! :P

use edit

btw idk how to global variable >>edit
Reply
#4

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

if im troll wait until ppl help you! NEW SLAUGHTER!
Reply
#6

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.
Reply
#7

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

Reply
#8

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

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?
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)