09.06.2012, 05:02
(
Последний раз редактировалось CidadeNovaRP; 10.06.2012 в 18:57.
)
Well, my first pay I believe Include ... Worked perfectly for me, it creates Include Timer's sequence, you define the amount of times this timer will repeat (loop), removing the need to create a variable for each time and use the "true".
He has three commands for macros:
LoopTimerCreate ("funcname", {Float, _}: ...)
- Used to create a function that will be used in the Sequence LoopTimerStart
Example:
LoopTimerEnd ("funcname", {Float, _}: ...)
- Called when the "funcname" is ended (when the sequence ends, the loop)
Example:
LoopTimerStart ("funcname", time, replications, "Const Format", {Float, _}: ...);
- Start Sequence according to the Time and Reps, etc.
Example:
Example Finale:
INCLUDE:
Sorry my bad Inglish.
Hope you like, comment!
Credits 100% for me.
Original Topic: http://forum.sa-mp.com/showthread.ph...16#post1912516
UPDATED FOR FINAL
SPEED - 0.2x SLOWER (DID IT)
OPTIMIZATION - 0.5 A MORE ENHANCED SIZE COMPARED. AMX
SIMPLICITY - 2/3x SIMPLER
DOWNLOAD OF TESTS / TEST CODES / INCLUDE:
He has three commands for macros:
LoopTimerCreate ("funcname", {Float, _}: ...)
- Used to create a function that will be used in the Sequence LoopTimerStart
Example:
pawn Код:
LoopTimerCreate("Perseguir", playerid, giveid)
{
new Float:Pos[3];
GetPlayerPos(giveid, Pos[0], Pos[1], Pos[2]);
SetPlayerCheckpoint(playerid, Pos[0], Pos[1], Pos[2], 3.0);
return 1;
}
LoopTimerEnd ("funcname", {Float, _}: ...)
- Called when the "funcname" is ended (when the sequence ends, the loop)
Example:
pawn Код:
LoopTimerEnd("Perseguir", playerid, giveid)
{
DisablePlayerCheckpoint(playerid);
printf("Loop Timer Finished");
return 1;
}
LoopTimerStart ("funcname", time, replications, "Const Format", {Float, _}: ...);
- Start Sequence according to the Time and Reps, etc.
Example:
pawn Код:
LoopTimerStart("Perseguir", 1000, time, "ii", playerid, giveid);
Example Finale:
pawn Код:
#include a_samp
#include zcmd
#include sscanf
#include looptimer
LoopTimerCreate("Perseguir", playerid, giveid)
{
new Float:Pos[3];
GetPlayerPos(giveid, Pos[0], Pos[1], Pos[2]);
SetPlayerCheckpoint(playerid, Pos[0], Pos[1], Pos[2], 3.0);
return 1;
}
LoopTimerEnd("Perseguir", playerid, giveid)
{
DisablePlayerCheckpoint(playerid);
printf("Loop Timer Finished");
return 1;
}
CMD:falow(playerid, params[])
{
new giveid, time;
if(sscanf(params, "dd", giveid, time)) return SendClientMessage(playerid, -1, "USAGE: /falow[ID] [TIME IN SG]");
LoopTimerStart("Perseguir", 1000, time, "ii", playerid, giveid);
return 1;
}
INCLUDE:
pawn Код:
#include a_samp
#if defined tabsize
#undef tabsize
#endif
#pragma tabsize 0
#define LoopTimerCreate("%0",%1) \
forward Func_%0(%1); \
forward End_%0(%1); \
public Func_%0(%1)
#define LoopTimerStart(%0,%1,%2,%3,%4) \
for(new c, f[36]; c < %2; c++) \
{ \
format(f, sizeof(f), "%s", %0); \
if(c == %2 - 1) \
{ \
strins(f, "End_", 0); \
SetTimerEx(f, %1*c, false, "%3", %4); \
} \
else \
{ \
strins(f, "Func_", 0); \
SetTimerEx(f, %1*c, false, "%3", %4); \
} \
} \
FuncNone()
#define LoopTimerEnd("%0",%1) \
public End_%0(%1)
stock FuncNone()
{
}
Sorry my bad Inglish.
Hope you like, comment!
Credits 100% for me.
Original Topic: http://forum.sa-mp.com/showthread.ph...16#post1912516
UPDATED FOR FINAL
SPEED - 0.2x SLOWER (DID IT)
OPTIMIZATION - 0.5 A MORE ENHANCED SIZE COMPARED. AMX
SIMPLICITY - 2/3x SIMPLER
DOWNLOAD OF TESTS / TEST CODES / INCLUDE: