Is this possible?
#1

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.
Reply
#2

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

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

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

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.
Reply
#6

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.
Reply
#7

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.
Reply
#8

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.
Reply
#9

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)]");
}
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)