How to do this?
#1

How can I turn a string into a variable?

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

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

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;

Reply
#4

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)