SA-MP Forums Archive
[CODE] /accept command - 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: [CODE] /accept command (/showthread.php?tid=332474)



[CODE] /accept command - squomp - 08.04.2012

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


Re: [CODE] /accept command - [DOG]irinel1996 - 08.04.2012

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.


Re: [CODE] /accept command - squomp - 08.04.2012

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


Re: [CODE] /accept command - ReneG - 08.04.2012

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?


Re: [CODE] /accept command - squomp - 08.04.2012

thanks this helped me out alot


Re: [CODE] /accept command - EstSampBro - 16.06.2013

deleted