//Let's say I had a var called PlayerInfo[playerid][pAdmin] and it equals 2.
function(blah[]) //blah in this case would be "pAdmin"
{
new string[128],stat[32];
format(stat,sizeof(stat),"PlayerInfo[playerid][%s]",blah); //at this point the string should read as "PlayerInfo[playerid][pAdmin]"
format(string,sizeof(string),"The value of this stat is %i.",stat); //here's where the issue is since stat is a string and not an integer
SendClientMessage(playerid,-1,string);
}
format(string,sizeof(string),"The value of this stat is %i.",PlayerInfo[playerid][pAdmin]);
#include <a_samp>
enum E_PLAYER_DATA {
pAdmin
};
new PlayerInfo[MAX_PLAYERS][E_PLAYER_DATA];
main() {
new
playerid = 10
;
printf("[BEFORE] Player[%d][pAdmin] == %d", playerid, PlayerInfo[playerid][pAdmin]);
Increase_Data(playerid, pAdmin);
printf("[AFTER] Player[%d][pAdmin] == %d", playerid, PlayerInfo[playerid][pAdmin]);
}
Increase_Data(playerid, E_PLAYER_DATA:enumerator) {
PlayerInfo[playerid][enumerator] ++;
return true;
}
function(blah[]) //still pAdmin
{
new string[128],stat[32];
format(stat,sizeof(stat),"PlayerInfo[playerid][%s]",blah);
format(string,sizeof(string),"The value of %s is %i.",blah,stat);
SendClientMessage(playerid,-1,string);
return 1;
}
#include <a_samp>
enum E_PLAYER_DATA {
pAdmin,
pLevel
};
new PlayerInfo[MAX_PLAYERS][E_PLAYER_DATA];
main() {
new
playerid = 10
;
Display_Data(playerid, pAdmin, #pAdmin);
Display_Data(playerid, pLevel, #pLevel);
}
Display_Data(playerid, E_PLAYER_DATA:enumerator, stringified[]) {
new string[128];
format(string,sizeof(string),"The value of %s is %i.", stringified, PlayerInfo[playerid][enumerator]);
print(string);
return true;
}
[04:57:52] The value of pAdmin is 0. [04:57:52] The value of pLevel is 0.
Assuming stringify means turning something into a string, how would you de-stringify a string into plain text to the script?
|