PDA

View Full Version : My timed kill command isn't working.


PlayHard
31/12/2011, 02:36 PM
stock killedplayer(playerid)
{
SetPlayerHealth(playerid, 0.000);
return 1;
}
YCMD:killme(playerid, params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;
{
SendClientMessage(playerid, COLOR_LIGHTRED,"Warning: You will get self-killed after 10-15 seconds...");
SetTimer("killedplayer", 14000, false);
TogglePlayerControllable(playerid, 0);
}
return 1;
}

It doesn't set the player's HP to 0, just freeze him :/.

Mosslah
31/12/2011, 02:40 PM
Why are you doing:

SetTimer("killedplayer", 14000, false);

You need to call a public with the funcname[], you cannot call a stock.

suhrab_mujeeb
31/12/2011, 02:40 PM
Use SetTimerEx for based on players timers.
SetTimerEx("FunctionName", Seconds * 1000, false, "i", playerid);

Norck
31/12/2011, 02:41 PM
Use

forward killedplayer(playerid);
public killedplayer(playerid)
{
SetPlayerHealth(playerid, 0.000);
return 1;
}

Instead of

stock killedplayer(playerid)
{
SetPlayerHealth(playerid, 0.000);
return 1;
}


And

SetTimerEx("killedplayer", 14000, false,"i",playerid);

Instead of

SetTimer("killedplayer", 14000, false);

suhrab_mujeeb
31/12/2011, 02:43 PM
Use

public killedplayer(playerid)
{
SetPlayerHealth(playerid, 0.000);
return 1;
}

Yea, and forward that too using:
forward killedplayer(playerid);
Put it below your includes.

NeverKnow
31/12/2011, 02:47 PM
here you go i help you :)

Top On Your Script: new killplayertimer[MAX_PLAYERS];

YCMD:killme(playerid, params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;
{
SendClientMessage(playerid, COLOR_LIGHTRED,"Warning: You will get self-killed after 10-15 seconds...");
killplayertimer[playerid] = SetTimerEx("killedplayer", 14000, 0, "d", playerid);
TogglePlayerControllable(playerid, 0);
}
return 1;
}

On your Killedplayer Function set:

forward Killedplayer(playerid);
public Killedplayer(playerid)
{
KillTimer(killplayertimer[playerid]);
SetPlayerHealth(playerid, 0 );
}

FireCat
31/12/2011, 02:48 PM
Uhh
He should do SetTimerEx...

forward killedplayer(playerid);
public killedplayer(playerid)
{
SetPlayerHealth(playerid, 0.000);
return 1;
}
YCMD:killme(playerid, params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;
{
SendClientMessage(playerid, COLOR_LIGHTRED,"Warning: You will get self-killed after 10-15 seconds...");
SetTimer("killedplayer", 14000, false,"i",playerid);
TogglePlayerControllable(playerid, 0);
}
return 1;
}

NeverKnow
31/12/2011, 02:49 PM
All doing wrong just Pickup my Codes :)))

Norck
31/12/2011, 02:50 PM
Yea, and forward that too using:
forward killedplayer(playerid);
Put it below your includes.

Thanks for correcting me. I've edited my post.

PlayHard
31/12/2011, 03:05 PM
@Everyone: Thanks a lot guys! I've done that but now I am having 2 warnings,

C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\ bc.pwn(2851) : warning 202: number of arguments does not match definition
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\ bc.pwn(2851) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Warnings.

Line:

SetTimer("killedplayer", 14000, false,"i",playerid);

Norck
31/12/2011, 03:19 PM
@Everyone: Thanks a lot guys! I've done that but now I am having 2 warnings,

C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\ bc.pwn(2851) : warning 202: number of arguments does not match definition
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\ bc.pwn(2851) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Warnings.

Line:

SetTimer("killedplayer", 14000, false,"i",playerid);

Use SetTimerEx instead of SetTimer

PlayHard
31/12/2011, 04:30 PM
Oh Lol, stupid me! Thank you ^^.