[CODE] /accept command
#1

How do you make a command that only works with the other players permission, can someone give me an example please?
Reply
#2

Quote:
Originally Posted by squomp
Посмотреть сообщение
How do you make a command that only works with the other players permission, can someone give me an example please?
What do you mean exactly with "other players permission", sorry, I didn't understand that.
Maybe my English is not good enough.
Reply
#3

say like - if a command makes another players armour full, it can only make the armour full if the player does /accept armour
Reply
#4

Here is an example using Apples! ( I didn't know what else to use )
pawn Код:
new
    Apples[MAX_PLAYERS], // A new variable for the apples
    bool:IsRecievingApples[MAX_PLAYERS]; // A bool that will be used in the /accept command
CMD:giveapple(playerid,params[])
{
    new
        target,
        string[128],
        name[24]
    ;
    if(sscanf(params,"d",target))
    {
        return SendClientMessage(playerid, -1, "USAGE: /giveapple [playerid]");
    }
    else
    {
        IsRecievingApples[target] = true; // Set the bool to true
        GetPlayerName(playerid,name,sizeof(name));
        format(string,sizeof(string),"%s has offered you an apple. Type /accept apple to accept it.",name);
        SendClientMessage(target,-1,string);
    }
    return 1;
}
CMD:accept(playerid,params[])
{
    new
        option[11]
    ;
    if(isnull(params))
    {
        return SendClientMessage(playerid,-1,"USAGE: /accept [name]");
    }
    if(!strcmp(option,"apple",true)) // If they type "apple"
    {
        // Then it'll check if someone has offered them apples
        if(IsRecievingApples[playerid] == true)
        {
            Apples[playerid]++; // Gives them an apple
            SendClientMessage(playerid,-1,"You have recieved an apple!");
            return 1;
        }
        else
        {
            SendClientMessage(playerid, -1, "No one has offered you apples.");
            return 1;
        }
    }
    return 1;
}
Tested.

EDIT:

Did you want the same thing, but for armour?
Reply
#5

thanks this helped me out alot
Reply
#6

deleted
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)