SA-MP Forums Archive
Write something in variable and then read specific information. - 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)
+--- Thread: Write something in variable and then read specific information. (/showthread.php?tid=541478)



Write something in variable and then read specific information. - Banditukas - 12.10.2014

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


Re: Write something in variable and then read specific information. - SickAttack - 12.10.2014

Just put the variable with its corresponding arguments.

Example:
pawn Код:
PlayerInfo[playerid][pXP]



Re: Write something in variable and then read specific information. - Banditukas - 12.10.2014

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


Re: Write something in variable and then read specific information. - Dignity - 12.10.2014

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


Re: Write something in variable and then read specific information. - Banditukas - 12.10.2014

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


Re: Write something in variable and then read specific information. - Rudy_ - 12.10.2014

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



Re: Write something in variable and then read specific information. - Dignity - 12.10.2014

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.


Re: Write something in variable and then read specific information. - Banditukas - 12.10.2014

No there is not.


Re: Write something in variable and then read specific information. - Rudy_ - 12.10.2014

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.


Re: Write something in variable and then read specific information. - Banditukas - 12.10.2014

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