How to make timer for pickup
#1

hi guys , im now scripting pickup script but i want to know how to set timer to use this pickup again because when i just pickup pickup it spams abuse for example
PHP код:
public OnPlayerPickUpPickup(playeridpickupid
PHP код:
       if(pickupid == armourz)
    {
        if(
GetPlayerMoney(playerid) < 3000) return GameTextForPlayer(playerid,"~r~You don't have enough money to buy armour",3000,5);
        else if(
GetPlayerMoney(playerid) >= 3000GivePlayerMoney(playerid,-3000) && SetPlayerArmour(playerid,100);
    } 
ty
Reply
#2

Everything is explaind here
but add it to the OnPlayerPickUpPickup
https://sampwiki.blast.hk/wiki/SetTimer
Reply
#3

give me example please i already try that and SetTimerEx but i dont know how to make it useable again like when timer end ...
When player pick up pickup and try to pickup at same second it SCM(playerid,0xFFFFFF,"You need to wait 10 sec");
and when 10 sec over and he try to pickup again he can take it
sorry for bad english
Reply
#4

new yourtimer[MAX_PLAYERS];

SetTimerEx("yourtimer", 5000, true, "i", playerid);

KillTimer(yourtimer[playerid]);
Reply
#5

Quote:
Originally Posted by Scrillex
Посмотреть сообщение
new yourtimer[MAX_PLAYERS];

SetTimerEx("yourtimer", 5000, true, "i", playerid);

KillTimer(yourtimer[playerid]);
ty , where to add KillTmer function pls ?
Reply
#6

Here is the code
Put the forward under the includes

pawn Код:
forward PickUpAgian(playerid);
replace it with yours:
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
    if(pickupid == armourz)
    {
        if(GetPVarInt(playerid,"PickUpUsed") == 1)
        {
           SendClientMessage(playerid,COLOR_RED,"You need to wait before buying a armor agian");
           return 1;
        }
        if(GetPlayerMoney(playerid) < 3000) return GameTextForPlayer(playerid,"~r~You don't have enough money to buy armour",3000,5);
        else if(GetPlayerMoney(playerid) >= 3000) GivePlayerMoney(playerid,-3000) && SetPlayerArmour(playerid,100);
        SetPVarInt(playerid,"PickUpUsed",1);
        SetTimer("PickUpAgian",1000*3*4,false,"i",playerid);
    }
and put this some where in your gamemode:
pawn Код:
public PickUpAgian(playerid)
{
    if(GetPVarInt(playerid, "PickUpUsed") == 1)
    {
       SetPVarInt(playerid, "PickUpUsed", 0);
       return 1;
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
Here is the code
Put the forward under the includes

pawn Код:
forward PickUpAgian(playerid);
replace it with yours:
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
    if(pickupid == armourz)
    {
        if(GetPVarInt(playerid,"PickUpUsed") == 1)
        {
           SendClientMessage(playerid,COLOR_RED,"You need to wait before buying a armor agian");
           return 1;
        }
        if(GetPlayerMoney(playerid) < 3000) return GameTextForPlayer(playerid,"~r~You don't have enough money to buy armour",3000,5);
        else if(GetPlayerMoney(playerid) >= 3000) GivePlayerMoney(playerid,-3000) && SetPlayerArmour(playerid,100);
        SetPVarInt(playerid,"PickUpUsed",1);
        SetTimer("PickUpAgian",1000*3*4,false,"i",playerid);
    }
and put this some where in your gamemode:
pawn Код:
public PickUpAgian(playerid)
{
    if(GetPVarInt(playerid, "PickUpUsed") == 1)
    {
       SetPVarInt(playerid, "PickUpUsed", 0);
       return 1;
    }
    return 1;
}
ty but still not working
errors
Код:
error 035: argument type mismatch (argument 2)
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition
full script
PHP код:
    if(pickupid == pickup)
    {
           if(
GetPVarInt(playerid,"PickUpUsed") == 1)
        {
        
SendClientMessage(playerid,COLOR_RED,"You need to wait before buying a armor agian");
        }
 
        
GivePlayerMoney(playerid,1);
        
SetPVarInt(playerid,"PickUpUsed",1);
        
SetTimer("PickUpAgian",10000,false,"i",playerid);
    } 
and i add that for sure
Код:
forward PickUpAgian(playerid);
public PickUpAgian(playerid)
{
    if(GetPVarInt(playerid, "PickUpUsed") == 1)
    {
       SetPVarInt(playerid, "PickUpUsed", 0);
       return 1;
    }
    return 1;
}
Reply
#8

show just lines..
Reply
#9

Post the lines that have the errors
Reply
#10

Quote:
Originally Posted by Ahmed10020
Посмотреть сообщение
ty but still not working
pawn Код:
if(pickupid == pickup)
    {
        if(GetPVarInt(playerid,"PickUpUsed") == 1)
        {
        SendClientMessage(playerid,COLOR_RED,"You need to wait before buying a armor agian");
        }
 
        GivePlayerMoney(playerid,1);
        SetPVarInt(playerid,"PickUpUsed",1);
        SetTimer("PickUpAgian",10000,false,"i",playerid); /////<<<<<<<
    }
}
pawn Код:
SetTimer("PickUpAgian",10000,false,"i",playerid);
//should be
SetTimerEx("PickUpAgian",10000,false,"i",playerid);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)