SA-MP Forums Archive
Is this possible? - 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: Is this possible? (/showthread.php?tid=318836)



Is this possible? - oliverrud - 16.02.2012

I'm not sure how to explain what I'm trying to do exactly, so therefore I'm gonna show first a "failed" example:

I currently got an enum, it contains ID etc...
pawn Код:
new string[20];
string="ID";
PlayerAccount[playerid][string]=1;
Now is it possible to do something along those lines, as shown above?
Like not exactly writing ID in it but instead setting a string to ID?

What I'm trying to do is to create a system in-game to set the information of an enum by example: /setenum playerid identifier data

Is this possible?
And yes, the code above gives an error.


Re: Is this possible? - devil77771 - 16.02.2012

I think that it imposdible...
True: if(!strcmp(string, "ID", true)) PlayerAccount[playerid][ID] = 1;


Re: Is this possible? - [MG]Dimi - 16.02.2012

Eventually something with stock and Player Data ID but I don't think that you can do something like your example.


Re: Is this possible? - oliverrud - 16.02.2012

BUMP, nobody knows EXACTLY whether this is actually possible or not?


Re: Is this possible? - Toreno - 16.02.2012

You want creating enum data in game using commands? if so, I'm not sure, since I think there is no way of letting an enum read from a file so it will read the data you were saving in game using commands.


Re: Is this possible? - oliverrud - 16.02.2012

Quote:
Originally Posted by Toreno
Посмотреть сообщение
You want creating enum data in game using commands? if so, I'm not sure, since I think there is no way of letting an enum read from a file so it will read the data you were saving in game using commands.
No, I'm not trying to create enum data in-game. I'm trying to change it, however that's not the problem, its identifying, what ( Just gonna call it row since I don't really know the actual name ) row I'm wanting to change by making it dynamic or however you want to call it, so I could do:

/setenum 1 ID 2
/setenum 1 Name Gay
etc...

I know I could just string compare them inputs, however that would require me to add more code onto the setenum command everytime I were to add another row into the enum table.


Re: Is this possible? - Tannz0rz - 16.02.2012

Perhaps you're looking for something along the lines of this.

Though, I honestly think you'd just be better off avoiding these work-arounds.


Re: Is this possible? - [MG]Dimi - 17.02.2012

Actually I think I know how would you be able to do it. Use ZCMD. Check has he typed all params. Then you strcmp to check is second parameter same as any variable. If yes you set it. But you can't use typed enum from command. Ex.
pawn Код:
if(!strcmp(param2,"ID",true)) PlayerInfo[param1][ID] = param3;
else if(!strcmp(param2,"Kills",true)) PlayerInfo[param1][Kills] = param3;
...
Hope you understood and that that's what you are looking for.


Re : Is this possible? - ricardo178 - 17.02.2012

Humm... The most similar thing you can do is create an enum like:
pawn Код:
enum sInfo
{
    enum1
    enum2
    enum3
    enum4
    enum5
}
new ServerInfo[sInfo];
And now, you can create command like:
pawn Код:
CMD:setenum1(playerid, params[])
{
    new value;
    if(!sscanf(params, "d", value))
    {
        if(value == 1 && 5)
        {
            ServerInfo[enum1] = value;
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF, "Avaliable Values: 1, 2, 3, 4, 5.");
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setenum1 [Value(1-5)]");
}
CMD:setenum2(playerid, params[])
{
    new value;
    if(!sscanf(params, "d", value))
    {
        if(value == 1 && 5)
        {
            ServerInfo[enum2] = value;
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF, "Avaliable Values: 1, 2, 3, 4, 5.");
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setenum2 [Value(1-5)]");
}
CMD:setenum3(playerid, params[])
{
    new value;
    if(!sscanf(params, "d", value))
    {
        if(value == 1 && 5)
        {
            ServerInfo[enum3] = value;
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF, "Avaliable Values: 1, 2, 3, 4, 5.");
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setenum3 [Value(1-5)]");
}
CMD:setenum4(playerid, params[])
{
    new value;
    if(!sscanf(params, "d", value))
    {
        if(value == 1 && 5)
        {
            ServerInfo[enum4] = value;
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF, "Avaliable Values: 1, 2, 3, 4, 5.");
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setenum4 [Value(1-5)]");
}
CMD:setenum5(playerid, params[])
{
    new value;
    if(!sscanf(params, "d", value))
    {
        if(value == 1 && 5)
        {
            ServerInfo[enum5] = value;
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF, "Avaliable Values: 1, 2, 3, 4, 5.");
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setenum5 [Value(1-5)]");
}



Re: Is this possible? - milanosie - 17.02.2012

Ricardo ur using if its 1 and 5 at the same time. Not if between