SA-MP Forums Archive
How to make timer for pickup - 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)
+--- Thread: How to make timer for pickup (/showthread.php?tid=470420)



How to make timer for pickup - Ahmed10020 - 17.10.2013

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


Re: How to make timer for pickup - DarkLored - 18.10.2013

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


Re: How to make timer for pickup - Ahmed10020 - 18.10.2013

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


Re: How to make timer for pickup - Scrillex - 18.10.2013

new yourtimer[MAX_PLAYERS];

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

KillTimer(yourtimer[playerid]);


Re: How to make timer for pickup - Ahmed10020 - 18.10.2013

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 ?


Re: How to make timer for pickup - DarkLored - 18.10.2013

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



Re: How to make timer for pickup - Ahmed10020 - 18.10.2013

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



Re: How to make timer for pickup - Scrillex - 18.10.2013

show just lines..


Re: How to make timer for pickup - DarkLored - 18.10.2013

Post the lines that have the errors


Re: How to make timer for pickup - Laronic - 18.10.2013

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