[HELP]Luck Sustem
#2

In your best interest I have put a timer on it and an anti-spam function.

pawn Код:
#define FindTobacoTime 5000 //Time in milliseconds it takes to find tobaco
forward ProcessTobacoFind(playerid);
pLastTobacoFind[MAX_PLAYERS];
pSpamalot[MAX_PLAYERS];
Float:pLastStand[MAX_PLAYERS][3];
public OnPlayerConnect(playerid)
{
  pLastTobacoFind[playerid]=gettick();
  return 1;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
  if(!strcmp(cmdtext[1],"tobaco",true))
  {
    pSpamalot[playerid]++;
    if(pSpamalot[playerid]>5)
    {
      pLastTobacoFind[playerid]=gettick()+3600000; //3600000 MS = 1 hour, you should probably change this.
      pSpamalot[playerid]=0;
      SendClientMessage(playerid,0xFF0000FF,"You have spammed, you're banned from this command for 1 hour");
      return SendClientMessage(playerid,0xFF0000FF,"Typing the command in more will just make you wait longer.");
    }
    if(pLastTobacoFind[playerid]>gettick()) return SendClientMessage(playerid,0xFF0000FF,"You cannot do that yet!");
    pSpamalot[playerid]=0;
    SetTimerEx("ProcessTobacoFind",FindTobacoTime,0,"i",playerid);
    pLastTobacoFind[playerid]=gettick();
    GetPlayerPos(playerid,pLastStand[playerid][0],pLastStand[playerid][1],pLastStand[playerid][2]);
    SendClientMessage(playerid,0xFF0000FF,"You have started looking for tobaco leaves.");
    return SendClientMessage(playerid,0xFF0000FF,"If you move, you won't find any.");
  }
  return 0;
}
public ProcessTobacoFind(playerid)
{
  if(IsPlayerInRangeOfPoint(playerid,pLastStand[0],pLastStand[1],pLastStand[2])>0)return SendClientMessage(playerid,0xFF0000FF,"You didn't find any tobaco leaves.");
  new temp = random(100);
  new find;
  if(temp<33)return SendClientMessage(playerid,0xFF0000FF,"You didn't find any tobaco leaves."); //33% chance of failure
  else if(temp<70)find = 1; //37% chance to find only 1
  else if(temp<90)find = 2; //20% chance to find 2
  else find = 3; //10% chance to find 3
  new tmpstring[100];
  format(tmpstring,sizeof(tmpstring),"You have found %d leave(s).",find);
  AddItemToPlayerInventory(playerid,1,find,"Item");//This is YOUR function, not sure how to use it
  return SendClientMessage(playerid,0xFF0000FF,tmpstring);
}
Reply


Messages In This Thread
[HELP]Luck Sustem - by Giotis11 - 13.01.2010, 16:51
Re: [HELP]Luck Sustem - by Joe Staff - 13.01.2010, 17:33
Re: [HELP]Luck Sustem - by Giotis11 - 13.01.2010, 18:29
Re: [HELP]Luck Sustem - by Joe Staff - 13.01.2010, 22:20
Re: [HELP]Luck Sustem - by Giotis11 - 14.01.2010, 12:00
Re: [HELP]Luck Sustem - by Giotis11 - 14.01.2010, 20:03
Re: [HELP]Luck Sustem - by Joe Staff - 14.01.2010, 21:13
Re: [HELP]Luck Sustem - by Retardedwolf - 14.01.2010, 23:38
Re: [HELP]Luck Sustem - by Giotis11 - 15.01.2010, 11:27
Re: [HELP]Luck Sustem - by wiilweer - 15.01.2010, 15:54

Forum Jump:


Users browsing this thread: 3 Guest(s)