SA-MP Forums Archive
How to do this? - 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: How to do this? (/showthread.php?tid=656164)



How to do this? - MRM - 08.07.2018

How can I turn a string into a variable?

Example:
PHP код:
Player[playerid][%s] = 1;
s is a string defined in the enum



Re: How to do this? - Dayrion - 08.07.2018

What do you mean?
I guess, you should use enumeration: https://sampforum.blast.hk/showthread.php?tid=318307


Re: How to do this? - MRM - 08.07.2018

Another example for better expression:

PHP код:
dcmd_enum(playerid,params[])
{
    new 
string[32];
    if(
sscanf(params,"s[32]",string)){
        
SendClientMessage(playerid,COLOR_ERROR,"Use: /var enum");
        return 
1;
    }
    
printf("%d",Player[playerid][string])
    return 
1;




Re: How to do this? - Dayrion - 08.07.2018

Read the post I linked.
By the way, don't use dcmd but izcmd, zcmd or any better command processor.


Re: How to do this? - SyS - 09.07.2018

You can't dynamically name a variable or create one.Variable names are for programmer' understanding.
If you want to use string as a key for accessing a member in compound data there are some plugins which implement hash map in pawn. Like this https://github.com/BigETI/pawn-map