Drugs help
#1

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.
Reply
#2

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;
}

Reply
#3

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, .
Reply
#4

Well, fix those errors,
Reply
#5

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.
Reply
#6

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
Reply
#7

[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;
}
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)