08.04.2012, 10:52
How do you make a command that only works with the other players permission, can someone give me an example please?
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;
}