SA-MP Forums Archive
Drugs help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Drugs help (/showthread.php?tid=102319)



Drugs help - Jordan69 - 14.10.2009

hi , I need help. I've got a server, and It has the job ' DrugDealer'. When people get it, they go to D1 or D2. Then they buy drugs ect; but when they sell, they can keep spamming it.. I don't get it? O_O How do I add a timer, for example they wait 30 seconds before they can sell drugs to someone else again?

Thanks.


Re: Drugs help - ilikepie2221 - 14.10.2009

Use SetTimerEx when they sell drugs, and make a variable to save the seconds that have passed. For example:

pawn Код:
new
   drugstimer[MAX_PLAYERS];
   drugtimer;

forward SellDrugTimer(playerid);

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp("/selldrugs",cmdtext,true) == 0)
  {
    if(drugstimer[playerid] == 0)
    {
      // Code to sell the drug
      drugtimer = SetTimerEx("SellDrugTimer",1000,true,playerd);
      return 1;
    }
    if(drugstimer[playerid] >= 1)
    {
      SendClientMessage(Well, yeah);
      return 1;
    }
  }
  return 0;
}

public SellDrugTimer(playerid)
{
  if(drugstimer[playerid] => 1)
    drugstimer[playerid] -= 1;
  if(drugstimer[playerid] == 1)
    KillTimer(drugtimer);
  return 1;
}




Re: Drugs help - Jordan69 - 14.10.2009

Quote:
Originally Posted by ilikepie2221
Use SetTimerEx when they sell drugs, and make a variable to save the seconds that have passed. For example:

pawn Код:
new
   drugstimer[MAX_PLAYERS];
   drugtimer;

forward SellDrugTimer(playerid);

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp("/selldrugs",cmdtext,true) == 0)
  {
    if(drugstimer[playerid] == 0)
    {
      // Code to sell the drug
      drugtimer = SetTimerEx("SellDrugTimer",1000,true,playerd);
      return 1;
    }
    if(drugstimer[playerid] >= 1)
    {
      SendClientMessage(Well, yeah);
      return 1;
    }
 }
 return 0;
}

public SellDrugTimer(playerid)
{
  if(drugstimer[playerid] => 1)
    drugstimer[playerid] -= 1;
  if(drugstimer[playerid] == 1)
    KillTimer(drugtimer);
  return 1;
}
Well I added it, now I get 14 errors. BTW, Im using GF edit.. so Im really confuzed, .


Re: Drugs help - ilikepie2221 - 14.10.2009

Well, fix those errors,


Re: Drugs help - Abernethy - 14.10.2009

Quote:
Originally Posted by Jordan69
Quote:
Originally Posted by ilikepie2221
Use SetTimerEx when they sell drugs, and make a variable to save the seconds that have passed. For example:

pawn Код:
new
   drugstimer[MAX_PLAYERS];
   drugtimer;

forward SellDrugTimer(playerid);

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp("/selldrugs",cmdtext,true) == 0)
  {
    if(drugstimer[playerid] == 0)
    {
      // Code to sell the drug
      drugtimer = SetTimerEx("SellDrugTimer",1000,true,playerd);
      return 1;
    }
    if(drugstimer[playerid] >= 1)
    {
      SendClientMessage(Well, yeah);
      return 1;
    }
 }
 return 0;
}

public SellDrugTimer(playerid)
{
  if(drugstimer[playerid] => 1)
    drugstimer[playerid] -= 1;
  if(drugstimer[playerid] == 1)
    KillTimer(drugtimer);
  return 1;
}
Well I added it, now I get 14 errors. BTW, Im using GF edit.. so Im really confuzed, .
He was just giving you an example, post your /selldrugs command & i'll add it.


Re: Drugs help - Jordan69 - 15.10.2009

Quote:
Originally Posted by Abernethy♥
Quote:
Originally Posted by Jordan69
Quote:
Originally Posted by ilikepie2221
Use SetTimerEx when they sell drugs, and make a variable to save the seconds that have passed. For example:

pawn Код:
new
   drugstimer[MAX_PLAYERS];
   drugtimer;

forward SellDrugTimer(playerid);

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp("/selldrugs",cmdtext,true) == 0)
  {
    if(drugstimer[playerid] == 0)
    {
      // Code to sell the drug
      drugtimer = SetTimerEx("SellDrugTimer",1000,true,playerd);
      return 1;
    }
    if(drugstimer[playerid] >= 1)
    {
      SendClientMessage(Well, yeah);
      return 1;
    }
 }
 return 0;
}

public SellDrugTimer(playerid)
{
  if(drugstimer[playerid] => 1)
    drugstimer[playerid] -= 1;
  if(drugstimer[playerid] == 1)
    KillTimer(drugtimer);
  return 1;
}
Well I added it, now I get 14 errors. BTW, Im using GF edit.. so Im really confuzed, .
He was just giving you an example, post your /selldrugs command & i'll add it.
Quote:

}
if(strcmp(cmd, "/givepot", true) == 0)
{
if (PlayerInfo[playerid][pAdmin] >= 4)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /givepot [playerid/PartOfName] [amount]");
return 1;
}
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /givepot [playerid/PartOfName] [amount]");
return 1;
}
new playa;
GetPlayerName(playa, sendername, sizeof(sendername));
playa = ReturnUser(tmp);
moneys = strval(tmp);
PlayerInfo[giveplayerid][pPot] = moneys;
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, 256, "[AdmWarning]: %s has given %s %d Pot.", sendername, giveplayer, moneys);
ABroadCast(COLOR_YELLOW,string,1);
if (PlayerInfo[playerid][pAdmin] < 1337)
{

also same with /givecrack


Re: Drugs help - Abernethy - 15.10.2009

[pawn]
// Top of script
new bool:SoldPotRecently[MAX_PLAYERS];

forward GivePotDelay(playerid);

// I fixed the indentation, but
pawn Код:
codes fucked it, lol.
if(strcmp(cmd, "/givepot", true) == 0)
{
    if (PlayerInfo[playerid][pAdmin] >= 4)
    {
        if(IsPlayerConnected(playerid))
        {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /givepot [playerid/PartOfName] [amount]");
            return 1;
        }
      giveplayerid = ReturnUser(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
      {
        SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /givepot [playerid/PartOfName] [amount]");
        return 1;
        }
        if (SoldPotRecently[playerid] == true)
      {
                SendClientMessage(playerid, COLOR_RED, "Please wait 1 minute before selling pot again!");
                SetTimerEx("GivePotDelay", 60000, false, "i", playerid);
                return true;
            }
            new playa;
        GetPlayerName(playa, sendername, sizeof(sendername));
        playa = ReturnUser(tmp);
        moneys = strval(tmp);
        PlayerInfo[giveplayerid][pPot] = moneys;
        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, 256, "[AdmWarning]: %s has given %s %d Pot.", sendername, giveplayer, moneys);
            SoldPotRecently[playerid] = true;
      ABroadCast(COLOR_YELLOW,string,1);
      // That is as far as you posted.
     
public GivePotDelay(playerid)
{
    SendClientMessage(playerid, COLOR_GRAD1, "You can now sell pot!");
    SoldPotRecently[playerid] = false;
    return true;
}



Re: Drugs help - Matthew_Murdoch - 15.10.2009

Quote:

Well I added it, now I get 14 errors. BTW, Im using GF edit.. so Im really confuzed, .

THAT the problem, GF edit, really try to code, it helps, GF edit isnt really helping you