SA-MP Forums Archive
Timer - 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: Timer (/showthread.php?tid=281244)



Timer - dahley5 - 04.09.2011

Hi, i was wondering, how do i make a timer? and how does this work? I want to make one for my CC script.


Re: Timer - Kingunit - 04.09.2011

What kind of timer you need? What function he need to call?

// https://sampwiki.blast.hk/wiki/SetTimerEx


Re: Timer - Bakr - 04.09.2011

Everything you would possibly need can be found here:

https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetTimerEx


Re: Timer - dahley5 - 04.09.2011

Thanks for this, here is a script i want to make a timer for, its for a cruise control script in my server:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_SECONDARY_ATTACK))
    {
        new Float:vX, Float:vY, Float:vZ;
        GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
        SetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
        SendClientMessage(playerid, COLOR_ORANGE,"Cruise control has been enabled!");
    }
    return 1;
}
EDIT: i do know how to set a timer for e.g a server announcement, but how do i do it for this script?


Re: Timer - dahley5 - 04.09.2011

??


Re: Timer - dowster - 04.09.2011

What do you want the timer to do?

Edit: Also this may help https://sampforum.blast.hk/showthread.php?tid=281002


Re: Timer - =WoR=Varth - 05.09.2011

pawn Код:
new Timer[MAX_PLAYERS];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_SECONDARY_ATTACK))
    {
        new Float:vX, Float:vY, Float:vZ,vid = GetPlayerVehicleID(playerid);
        GetVehicleVelocity(vid, vX, vY, vZ);
        Timer[playerid] = SetTimerEx("ASDQWE",200,1,"dfff",vid,vX,vY,vZ);
        SendClientMessage(playerid, COLOR_ORANGE,"Cruise control has been enabled!");
    }
    return 1;
}

forward ASDQWE(vehicleid,Float:x,Float:y,Float:z);
public ASDQWE(vehicleid,Float:x,Float:y,Float:z) return SetVehicleVelocity(vehicleid,x,y,z);



Re: Timer - dahley5 - 05.09.2011

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
pawn Код:
new Timer[MAX_PLAYERS];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_SECONDARY_ATTACK))
    {
        new Float:vX, Float:vY, Float:vZ,vid = GetPlayerVehicleID(playerid);
        GetVehicleVelocity(vid, vX, vY, vZ);
        Timer[playerid] = SetTimerEx("ASDQWE",200,1,"dfff",vid,vX,vY,vZ);
        SendClientMessage(playerid, COLOR_ORANGE,"Cruise control has been enabled!");
    }
    return 1;
}

forward ASDQWE(vehicleid,Float:x,Float:y,Float:z);
public ASDQWE(vehicleid,Float:x,Float:y,Float:z) return SetVehicleVelocity(vehicleid,x,y,z);
Thanks! but where do i put the last 2 lines?

pawn Код:
forward ASDQWE(vehicleid,Float:x,Float:y,Float:z);
public ASDQWE(vehicleid,Float:x,Float:y,Float:z) return SetVehicleVelocity(vehicleid,x,y,z);



Re: Timer - =WoR=Varth - 05.09.2011

Quote:
Originally Posted by dahley5
Посмотреть сообщение
Thanks! but where do i put the last 2 lines?

pawn Код:
forward ASDQWE(vehicleid,Float:x,Float:y,Float:z);
public ASDQWE(vehicleid,Float:x,Float:y,Float:z) return SetVehicleVelocity(vehicleid,x,y,z);
Whereever you want outside any callback and function.


Re: Timer - dahley5 - 05.09.2011

ok, thanks