[SetTimer] i need help
#1

i have a menu where u can get a gun and armor but i wanna set a timer so theres no abuse. how can i put a timer to stop someone from getting the guns multiple times? like lets say you get a gun and then a timer starts for like 2 minutes and if u try to get a gun while the timer is running it send a message saying "You cant do this again yet". how would i put it so it gets the time on the timer to let the player get a gun or not?

if am not clear let me no plz cuz i dnt think i am. thnx.
Reply
#2

Is the menu opened by a command or by picking up a pickup? :O
Reply
#3

i have a pickup in grove street if you walk in it and your player color is green(for grove street) then it opens the menu.
Reply
#4

Top of the script:
pawn Код:
forward DisMenu(playerid);
and
pawn Код:
new DisableMenu[MAX_PLAYERS];
pawn Код:
public DisMenu(playerid)
{
     DisableMenu[playerid] = 0;
     return 1;
}
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == Blabla)
    {
         if(DisableMenu[playerid] == 0)
         {
               //ShowMenu-Code
         }
    }
    return 1;
}
Now where you get the weapon, add:
pawn Код:
DisableMenu[playerid] = 1;
and
pawn Код:
SetTimerEx("DisMenu", 120000, false, "d", playerid);
Reply
#5

Quote:
Originally Posted by Last_Stand_Guardian
Top of the script:
pawn Код:
forward DisMenu(playerid);
and
pawn Код:
new DisableMenu[MAX_PLAYERS];
pawn Код:
public DisMenu(playerid)
{
    DisableMenu[playerid] = 0;
    return 1;
}
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
   if(pickupid == Blabla)
   {
         if(DisableMenu[playerid] == 0)
         {
              //ShowMenu-Code
         }
   }
   return 1;
}
Now where you get the weapon, add:
pawn Код:
DisableMenu[playerid] = 1;
and
pawn Код:
SetTimerEx("DisMenu", 120000, false, "d", playerid);

i get these errors:

C:\Users\Guest\Desktop\New folder\gamemodes\Untitled.pwn(22) : error 021: symbol already defined: "DisableMenu"
C:\Users\Guest\Desktop\New folder\gamemodes\Untitled.pwn(25) : error 028: invalid subscript (not an array or too many subscripts): "DisableMenu"
C:\Users\Guest\Desktop\New folder\gamemodes\Untitled.pwn(25) : warning 215: expression has no effect
C:\Users\Guest\Desktop\New folder\gamemodes\Untitled.pwn(25) : error 001: expected token: ";", but found "]"
C:\Users\Guest\Desktop\New folder\gamemodes\Untitled.pwn(25) : error 029: invalid expression, assumed zero
C:\Users\Guest\Desktop\New folder\gamemodes\Untitled.pwn(25) : fatal error 107: too many error messages on one line


the top of my script is:

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
//--------------------------------------------------//
#define COLOUR_GREEN 0x33AA33AA
#define COLOUR_RED 0xAA3333AA
#define COLOUR_YELLOW 0xFFFF00AA
#define COLOUR_LIGHTBLUE 0x33CCFFAA
#define COLOUR_ORANGE 0xFF9900AA
#define TEAM_GROVE 1
#define TEAM_POLICE 2
#define TEAM_AZTECS 3
#define TEAM_BALLAS 4
#define TEAM_GROVE_COLOR 0x77CC77FF
#define TEAM_POLICE_COLOR 0x7777DDFF
#define TEAM_AZTECS_COLOR 0x7777DDFF
#define TEAM_BALLAS_COLOR 0x7777DDFF
//-------------------------------------------------//
forward DisMenu(playerid);
new DisableMenu[MAX_PLAYERS];
public DisMenu(playerid)
{
DisableMenu[playerid] = 0;
return 1;
}
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}


Reply
#6

pawn Код:
public DisMenu(playerid)
{
     DisableMenu[playerid] = 0;
     return 1;
}
At the bottom ^^ then it seems to be correct =D
Reply
#7

Quote:
Originally Posted by Last_Stand_Guardian
pawn Код:
public DisMenu(playerid)
{
     DisableMenu[playerid] = 0;
     return 1;
}
At the bottom ^^ then it seems to be correct =D
New errors::

C:\Users\Guest\Desktop\New folder\gamemodes\Untitled.pwn(402) : error 028: invalid subscript (not an array or too many subscripts): "DisableMenu"
C:\Users\Guest\Desktop\New folder\gamemodes\Untitled.pwn(402) : warning 215: expression has no effect
C:\Users\Guest\Desktop\New folder\gamemodes\Untitled.pwn(402) : error 001: expected token: ";", but found "]"
C:\Users\Guest\Desktop\New folder\gamemodes\Untitled.pwn(402) : error 029: invalid expression, assumed zero
C:\Users\Guest\Desktop\New folder\gamemodes\Untitled.pwn(402) : fatal error 107: too many error messages on one line


Part of script:all indentation are correct it jus got messed up because i numbered them.)

396 new pColor;
397 public OnPlayerPickUpPickup(playerid, pickupid)
398 {
399 pColor = GetPlayerColor(playerid);
400 if(pickupid == gsmenup)
401 {
402 if(DisableMenu[playerid] == 0)
403 {
404 if(pColor == COLOUR_GREEN)
405 {
406 ShowMenuForPlayer(gsmenu, playerid);
407 }
408 else if(pColor /= COLOUR_GREEN)
409 {
410 SendClientMessage(playerid, 0xAA33AA33, "Your not GSF. You can't use this armory.");
411 }
412 }
413 }
414 return 1;
415 }
Reply
#8

Oh I've made an mistake xD

Rename
pawn Код:
new DisableMenu[MAX_PLAYERS];
by
pawn Код:
new StopMenu[MAX_PLAYERS];
So: Replace every DisableMenu[playerid], also with StopMenu[playerid]

xD I'm sorry ;( ^^
Forgotten that DisableMenu is a function already, so we can't use it as a variablename :O
Reply
#9

Quote:
Originally Posted by Last_Stand_Guardian
Oh I've made an mistake xD

Rename
pawn Код:
new DisableMenu[MAX_PLAYERS];
by
pawn Код:
new StopMenu[MAX_PLAYERS];
So: Replace every DisableMenu[playerid], also with StopMenu[playerid]

xD I'm sorry ;( ^^
Forgotten that DisableMenu is a function already, so we can't use it as a variablename :O
thnx it worked and it was partially my fault cuz i put all the menu actions for the gun under one case
[
case 0: GivePlayer.........
SetTimer........
StopMenu.....
]


but now its all cool. thnx alot!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)