PDA

View Full Version : My Timer is not working +Rep+


Rudy_
26/04/2012, 01:24 PM
I've tried everything to fix my SetTimeEx but it won't work... here's the timer.


SetTimerEx("ResetJumping", 2500, true, "d" , playerid); // i got forward ResetJumping..

For what i'm using it is..


IsJumping[MAX_PLAYERS];

and

public ResetJumping(playerid)
{
IsJumping[playerid] = 1;
return 1;
}

Full code


new
SuperJumpEnabled[MAX_PLAYERS],
Float:pX,
Float:pY,
Float:pZ,
IsJumping[MAX_PLAYERS];

forward ResetJumping(playerid);
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(SuperJumpEnabled[playerid] == 1)
{
if(newkeys & KEY_JUMP && SuperJumpEnabled[playerid])
{
GetPlayerVelocity(playerid, pX, pY, pZ);
SetPlayerVelocity(playerid, pX,pY, pZ+5);
SendClientMessage(playerid, COLOR_USE, "Super Jump De-Acticated");
SetTimerEx("ResetJumping", 2500, true, "d" , playerid);
}
return 1;
}
return 0;
}

public ResetJumping(playerid)
{
IsJumping[playerid] = 1;
return 1;
}

Command to enable/disable it.


command(jump, playerid, params[])
{
if(SuperJumpEnabled[playerid] == 0)
{
SuperJumpEnabled[playerid] = 1;
SendClientMessage(playerid, COLOR_USE, "Super Jump is now enabled.");
SetTimerEx("ResetJumping", 2500, true, "d" , playerid);
}
else
{
SuperJumpEnabled[playerid] = 0;
SendClientMessage(playerid, COLOR_USE, "Super jump is now disabled.");
}
return 1;
}

No errors
Please someone help me :/

Rudy_
26/04/2012, 01:59 PM
Bump please i need help :(

SuperViper
26/04/2012, 02:05 PM
Stop re-posting this thread. Change your OnPlayerKeyStateChange whole function to this.

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(SuperJumpEnabled[playerid] == 1)
{
if(newkeys & KEY_JUMP)
{
SuperJumpEnabled[playerid] = 0;
GetPlayerVelocity(playerid, pX, pY, pZ);
SetPlayerVelocity(playerid, pX,pY, pZ+5);
SendClientMessage(playerid, COLOR_USE, "Super Jump De-Acticated");
SetTimerEx("ResetJumping", 2500, false, "d" , playerid);
}
return 1;
}
return 0;
}

and change your timer function to

public ResetJumping(playerid)
{
IsJumping[playerid] = 1;
SetTimerEx("ResetJumping", 2500, false, "d" , playerid);
return 1;
}

Rudy_
26/04/2012, 02:11 PM
Still when i jump once velocity works ... but second time it don't jump high, i have to /jump again to activate it again.

ViniBorn
26/04/2012, 02:17 PM
SetPlayerVelocity don't work with numbers bigger than 1

Rudy_
26/04/2012, 02:19 PM
it don't makes the script "Not working" just even if it's 5 it will work like 1..

SuperViper
26/04/2012, 02:21 PM
Change your timer to

public ResetJumping(playerid)
{
SuperJumpEnabled[playerid] = 1;
SetTimerEx("ResetJumping", 2500, false, "d" , playerid);
return 1;
}

Also, remove

SetTimerEx("ResetJumping", 2500, true, "d" , playerid);

from your command.

ViniBorn
26/04/2012, 02:23 PM
You really need to use SuperJumpEnabled and IsJumping?

For your code, just one need exist

Rudy_
26/04/2012, 02:30 PM
Hm... it works sometiems but still buggy..
1) when i tap Jump_Key it sometimes jumps twice or 3 times. and sometimes it dosen't. btw,The timer works now.
2) when i type /jump to activate it and then jump it works (fine) i made it like so i have to wait 60 secs to use it again, but players can use /jump so it'll be activated again and players can use jump again without waiting.

SuperViper
26/04/2012, 02:36 PM
Make it so they can't use /jump until the timer is finished.

Rudy_
26/04/2012, 02:39 PM
Ok...

command(jump, playerid, params[])
{
if(SuperJumpEnabled[playerid] == 0)
{
SuperJumpEnabled[playerid] = 1;
SendClientMessage(playerid, COLOR_USE, "Super Jump is now enabled.");
SetTimerEx("ResetJumping", 6000, true, "d" , playerid);
SetTimerEx("JumpCMDUsed", 6000, true, "d", playerid);
}
if(JumpCMDUsed[playerid]) = 1;
{
return SendClientMessage(playerid, COLOR_USE, "You need to wait before using this command again");
}
else
{
SuperJumpEnabled[playerid] = 0;
SendClientMessage(playerid, COLOR_USE, "Super jump is now disabled.");
}
return 1;
}


C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 02) : warning 217: loose indentation
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 02) : error 028: invalid subscript (not an array or too many subscripts): "JumpCMDUsed"
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 02) : warning 215: expression has no effect
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 02) : error 001: expected token: ";", but found "]"
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 02) : error 029: invalid expression, assumed zero
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 02) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

ViniBorn
26/04/2012, 02:42 PM
if(JumpCMDUsed[playerid]) = 1;
if(JumpCMDUsed[playerid] == 1)

Rudy_
26/04/2012, 02:45 PM
Well

public JumpCMDUsed(playerid)
{
SuperJumpEnabled[playerid] = 1;
SetTimerEx("JumpCMDUsed", 6000, false, "d" , playerid);
return 1;
}



public JumpCMDUsed(playerid)
{
SuperJumpEnabled[playerid] = 1;
SetTimerEx("JumpCMDUsed", 6000, false, "d" , playerid);
return 1;
}


forward JumpCMDUsed(playerid);
command(jump, playerid, params[])
{
if(SuperJumpEnabled[playerid] == 0)
{
SuperJumpEnabled[playerid] = 1;
SendClientMessage(playerid, COLOR_USE, "Super Jump is now enabled.");
SetTimerEx("ResetJumping", 6000, true, "d" , playerid);
SetTimerEx("JumpCMDUsed", 6000, true, "d", playerid);
}
if(JumpCMDUsed[playerid]) = 1;
{
return SendClientMessage(playerid, COLOR_USE, "You need to wait before using this command again");
}
else
{
SuperJumpEnabled[playerid] = 0;
SendClientMessage(playerid, COLOR_USE, "Super jump is now disabled.");
}
return 1;
}


C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 09) : warning 217: loose indentation
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 09) : error 028: invalid subscript (not an array or too many subscripts): "JumpCMDUsed"
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 09) : warning 215: expression has no effect
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 09) : error 001: expected token: ";", but found "]"
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 09) : error 029: invalid expression, assumed zero
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 09) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

ViniBorn
26/04/2012, 02:51 PM
forward PublicJumpCMDUsed(playerid);
public PublicJumpCMDUsed(playerid)
{
SuperJumpEnabled[playerid] = 1;
SetTimerEx("JumpCMDUsed", 6000, false, "d" , playerid);
return 1;
}

command(jump, playerid, params[])
{
if(SuperJumpEnabled[playerid] == 0)
{
SuperJumpEnabled[playerid] = 1;
SendClientMessage(playerid, COLOR_USE, "Super Jump is now enabled.");
SetTimerEx("ResetJumping", 6000, true, "d" , playerid);
SetTimerEx("PublicJumpCMDUsed", 6000, true, "d", playerid);
}
if(JumpCMDUsed[playerid] == 1)
return SendClientMessage(playerid, COLOR_USE, "You need to wait before using this command again");
else
{
SuperJumpEnabled[playerid] = 0;
SendClientMessage(playerid, COLOR_USE, "Super jump is now disabled.");
}
return 1;
}

Rudy_
26/04/2012, 02:54 PM
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 37) : error 028: invalid subscript (not an array or too many subscripts): "PublicJumpCMDUsed"
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 37) : warning 215: expression has no effect
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 37) : error 001: expected token: ";", but found "]"
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 37) : error 029: invalid expression, assumed zero
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 37) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

ViniBorn
26/04/2012, 02:58 PM
new JumpCMDUsed[MAX_PLAYERS];

Rudy_
26/04/2012, 02:59 PM
Sorry it's fixed... look at my edit

C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 37) : error 028: invalid subscript (not an array or too many subscripts): "PublicJumpCMDUsed"
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 37) : warning 215: expression has no effect
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 37) : error 001: expected token: ";", but found "]"
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 37) : error 029: invalid expression, assumed zero
C:\Users\Hamza\Desktop\PAWN\gamemodes\Crysis.pwn(3 37) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

Rudy_
26/04/2012, 03:38 PM
I've fixed the errors but .. when i tap Jump_Key it jumps twice sometimes... and sometimes you don't need to wait for 6 secs..
and you can jump high even when /jump "Super jump" is disabled.
Command to activate/De-activate

command(jump, playerid, params[])
{
if(SuperJumpEnabled[playerid] == 0)
{
SuperJumpEnabled[playerid] = 1;
SendClientMessage(playerid, COLOR_USE, "Super Jump is now enabled.");
SetTimerEx("ResetJumping", 6000, true, "d" , playerid);
SetTimerEx("PublicJumpCMDUsed", 6000, true, "d", playerid); return SendClientMessage(playerid,COLOR_USE, "You need to wait before using this Command Again");
}
else if(SuperJumpEnabled[playerid] == 1)
{
SuperJumpEnabled[playerid] = 0;
SendClientMessage(playerid, COLOR_USE, "Super jump is now disabled.");
}
return 1;
}

Jump cmd/

new
SuperJumpEnabled[MAX_PLAYERS],
Float:pX,
Float:pY,
Float:pZ;

forward ResetJumping(playerid);
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(SuperJumpEnabled[playerid] == 1)
{
if(newkeys & KEY_JUMP)
{
SuperJumpEnabled[playerid] =0;
GetPlayerVelocity(playerid, pX, pY, pZ);
SetPlayerVelocity(playerid, pX,pY, pZ+5);
SetTimerEx("ResetJumping", 6000, false, "d" , playerid);
}
return 1;
}
return 0;
}
public ResetJumping(playerid)
{
SuperJumpEnabled[playerid] = 1;
SetTimerEx("ResetJumping", 6000, false, "d" , playerid);
return 1;
}


"New's"

forward PublicJumpCMDUsed(playerid);
public PublicJumpCMDUsed(playerid)
{
SuperJumpEnabled[playerid] = 1;
SetTimerEx("PublicJumpCMDUsed", 6000, false, "d" , playerid);
return 1;
}

I really need to fix it