Message work done then remove
#1

When someone type for example /works. He will get a list of 10 works. If he types /takework 1. He will do work 1. Then after his work how can i remove that WORK from /works? Just say me how to remove it from the /works list. Thank you.
Reply
#2

Код:
new PlayerWork[MAX_PLAYERS][MAX_WORK]; // Or whatever your variable is which stores player's work value, if its not like this, I suggest using it in array like this.
Now /works should be like.

Код:
new str[128];
for(new i=0; i<10; i++)
{
    format(str, 128, "Work %d: %s", i, YourWorkNameVariable);
    SendClientMessage(playerid, 0xFFFFFFFF, str);
}
Now to remove, make a command like this.

Код:
CMD:removework(playerid, arg[])
{    
    if(sscanf(arg, "i", workid)) return 1;
    if( i < 0 || i > 9) return 1;
    Work[playerid][i] = 0;
    SendClientMessage(playerid, 0xFFFFFFFF, "You successfully cleared work variable.");
    return 1;
}
Reply
#3

This will remove the work done? and re-arrange the works with 1 - 9 right?
Reply
#4

No, it wont arrange the works if not set, and if you want work to start from 1 rather than 0 then;

/works command:
Код:
for(new i=1; i<11; i++)
{
    new str[128];
    format(str, 128, "Work %d: %s", i, WorkName);
    SendClientMessage(playerid, 0xFFFFFFFF, str);
}
/removework which will remove the work and re-arrange works in a sequence.
Код:
    if(sscanf(arg, "i", workid)) return 1;
    PlayerWork[playerid][workid] = 0;
    for(new i=workid; i<11; i++)
    {
        if(i == 10) PlayerWork[playerid][10] = 0;
        else PlayerWork[playerid][i] = PlayerWork[playerid][i+1];
    }
Reply
#5

lmao i know this thing , i want the server to automatically remove the message. Like when he types /takework 1,
Then he gets that work. After he is done. It must be removed automatically. The thing you said is simple lmao.
Reply
#6

AH, sorry, I misunderstood, my bad. I'd suggest you to make a dialog for that.

This should contain all your work names.
Код:
new Work[MAX_WORKS][128];
/takework
Код:
    new str[512];
    for(new i=0; i<MAX_WORK; i++)
    {
        if(strlen(Work[i]) format(str, 512, "%s%s\n", str, Work[i]);
    }
    ShowPlayerDialog(playerid, 5000, DIALOG_STYLE_LIST, "Choose Work", str, "Choose", "Cancel");
OnPlayerDialogResponse
Код:
    if(dialogid == 5000)
    {
        if(response)
        {
             format(Work[listitem], 128, "");
             SendClientMessage(playerid, 0xFFFFFFFF, "Work taken and removed from the server.");
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)