Write something in variable and then read specific information.
#1

Hi,

If i have written in variable that value:

YourName: Name5 | YourXP: 522

How can i load from that variable what is yourname value after :, and how much xp is written after: . And i can to for ex: setplayerscore
Reply
#2

Just put the variable with its corresponding arguments.

Example:
pawn Код:
PlayerInfo[playerid][pXP]
Reply
#3

You don't understand...

Imaginage i have a variable HELLO[ MAX_PLAYERS ][ 50 ];

format( HELLO[ playerid ], 49,"YourName: Name5 | YourXP: 522");


Then how get from this variable HELLO[ playerid ] a value of name and XP? that name is Name5 And XP is 522
Reply
#4

pawn Код:
format( HELLO[ playerid ], 49,"YourName: %s | YourXP: %d", YourName[playerid], YourExp[playerid]);
Read more about specifiers here: https://sampwiki.blast.hk/wiki/Format
Reply
#5

I don't ask how to format it right, i ask how get now from HELLO[ playerid ] variable a value of YourName And YourXP
Reply
#6

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "HELLO[Playerid], 49,YourName: %s | YourXP: %d", name, Variable for your exp);
SendClientMessageToAll(-1, string);
Reply
#7

Quote:
Originally Posted by Banditukas
Посмотреть сообщение
I don't ask how to format it right, i ask how get now from HELLO[ playerid ] variable a value of YourName And YourXP
If you actually clicked the link I provided, you'd notice that it shows exactly what you want to know.
Reply
#8

No there is not.
Reply
#9

Quote:
Originally Posted by Banditukas
Посмотреть сообщение
No there is not.
Actually there is, But your case is a bit different. You can not use it like the way you want.
You need to have enums to store your data, and then read/load it. You have not stored the XP anywhere, thus you can't just tell the player that Your XP is 'that' ... Though you can get the player name easily.
Reply
#10

Look here:

Код:
new stats[401], stringstats[70];//those are the variables we will need in the stock
 	GetPlayerNetworkStats(playerid, stats, sizeof(stats));//this one will get the net stats
  	new len = strfind(stats, "Packetloss: ");//and this one will get the packetloss
   	new Float:packetloss = 0.0;//the float for the packetloss
    if(len != -1)
    {
    	strmid(stringstats, stats, len, strlen(stats));
     	new len2 = strfind(stringstats, "%");
      	if(len != -1)
       	{
        	strdel(stats, 0, strlen(stats));
         	strmid(stats, stringstats, len2-3, len2);
          	packetloss = floatstr(stats);
        }
    }
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)