stock randomEx(min, max)
{
new rand = random(max-min)+min;
return rand;
}
CMD:foodsearch(playerid,params[])
{
if(IsPlayerInRangeOfPoint(playerid, 50, 375.962463,-65.816848,1001.507812) || IsPlayerInRangeOfPoint(playerid, 50, 369.579528,-4.487294,1001.858886) || IsPlayerInRangeOfPoint(playerid, 50, 373.825653,-117.270904,1001.499511))
{
if(Hungry[playerid] > 5)
{
new rand = randomEx(1,3); //please verify this gives a 50/50 chance :)
if(rand == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "You find some food behind the counter and begin to eat it.");
SendClientMessage(playerid, COLOR_WHITE, "You are no longer hungry!");
ApplyAnimation(playerid,"FOOD","EAT_Burger",4.1,0,1,1,1,1);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
Hungry[playerid] = 0;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You did not find any food inside this store! Try again later!");
//I want to set a timer here, so the player won't be able to use /foodsearch again for a certain amount of time...Preferably about 5 minutes
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You are not hungry. You do not need to eat!");
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You can only search for food inside a Clucking Bell, Pizza Stack or Burger Shot!");
}
return 1;
}
new LastSFood[MAX_PLAYERS];
//OnPlayerConnect set it to 0
CMD:foodsearch(playerid,params[])
{
if(LastSFood[playerid]>gettime()) return SendClientMessage(playerid, -1, "{FF0000}Please wait 5 minute again to use this command");
if(IsPlayerInRangeOfPoint(playerid, 50, 375.962463,-65.816848,1001.507812) || IsPlayerInRangeOfPoint(playerid, 50, 369.579528,-4.487294,1001.858886) || IsPlayerInRangeOfPoint(playerid, 50, 373.825653,-117.270904,1001.499511))
{
if(Hungry[playerid] > 5)
{
new rand = randomEx(1,3); //please verify this gives a 50/50 chance :)
if(rand == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "You find some food behind the counter and begin to eat it.");
SendClientMessage(playerid, COLOR_WHITE, "You are no longer hungry!");
ApplyAnimation(playerid,"FOOD","EAT_Burger",4.1,0,1,1,1,1);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
Hungry[playerid] = 0;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You did not find any food inside this store! Try again later!");
LastSFood[playerid] = gettime()+60+60+60+60+60;
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You are not hungry. You do not need to eat!");
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You can only search for food inside a Clucking Bell, Pizza Stack or Burger Shot!");
}
return 1;
}
CMD:foodsearch(playerid,params[])
{
if(IsPlayerInRangeOfPoint(playerid, 50, 375.962463,-65.816848,1001.507812) || IsPlayerInRangeOfPoint(playerid, 50, 369.579528,-4.487294,1001.858886) || IsPlayerInRangeOfPoint(playerid, 50, 373.825653,-117.270904,1001.499511))
{
if(Hungry[playerid] > 5)
{
if(GetPVarInt(playerid,"food_timer") > gettime()) retrun SendClientMessage(playerid,-1,"TRY TATER"):
new rand = randomEx(1,3); //please verify this gives a 50/50 chance :)
if(rand == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "You find some food behind the counter and begin to eat it.");
SendClientMessage(playerid, COLOR_WHITE, "You are no longer hungry!");
ApplyAnimation(playerid,"FOOD","EAT_Burger",4.1,0,1,1,1,1);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
Hungry[playerid] = 0;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You did not find any food inside this store! Try again later!");
//I want to set a timer here, so the player won't be able to use /foodsearch again for a certain amount of time...Preferably about 5 minutes
}
SetPVarInt(playerid,"food_timer",gettime()+300);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You are not hungry. You do not need to eat!");
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You can only search for food inside a Clucking Bell, Pizza Stack or Burger Shot!");
}
return 1;
}
public OnPlayerConnect(playerid)
{
new LastSFood = 0;
}
|
Thanks so much! Really appreciate your help!
Is this correct? Code:
public OnPlayerConnect(playerid)
{
new LastSFood = 0;
}
|
new LastSFood[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
LastSFood[playerid] = 0;
}
