SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 31/12/2011, 03:36 PM   #1
PlayHard
Huge Clucker
 
PlayHard's Avatar
 
Join Date: Nov 2011
Location: In an apartment
Posts: 216
Reputation: 22
Default My timed kill command isn't working.

pawn Code:
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 :/.
PlayHard is offline   Reply With Quote
Old 31/12/2011, 03:40 PM   #2
Mosslah
Big Clucker
 
Join Date: Dec 2011
Posts: 74
Reputation: 10
Default Re: My timed kill command isn't working.

Why are you doing:

pawn Code:
SetTimer("killedplayer", 14000, false);

You need to call a public with the funcname[], you cannot call a stock.
Mosslah is offline   Reply With Quote
Old 31/12/2011, 03:40 PM   #3
suhrab_mujeeb
Guest
 
Posts: n/a
Default Re: My timed kill command isn't working.

Use SetTimerEx for based on players timers.
pawn Code:
SetTimerEx("FunctionName", Seconds * 1000, false, "i", playerid);
  Reply With Quote
Old 31/12/2011, 03:41 PM   #4
Norck
Huge Clucker
 
Norck's Avatar
 
Join Date: Aug 2008
Location: Ukraine, Simferopol
Posts: 388
Reputation: 43
Default Re: My timed kill command isn't working.

Use
pawn Code:
forward killedplayer(playerid);
public killedplayer(playerid)
{
    SetPlayerHealth(playerid, 0.000);
    return 1;
}
Instead of
pawn Code:
stock killedplayer(playerid)
{
    SetPlayerHealth(playerid, 0.000);
    return 1;
}

And
pawn Code:
SetTimerEx("killedplayer", 14000, false,"i",playerid);
Instead of
pawn Code:
SetTimer("killedplayer", 14000, false);
__________________
Releases: fly.inc

Last edited by Norck; 31/12/2011 at 03:49 PM. Reason: just forget to add forward
Norck is offline   Reply With Quote
Old 31/12/2011, 03:43 PM   #5
suhrab_mujeeb
Guest
 
Posts: n/a
Default Re: My timed kill command isn't working.

Quote:
Originally Posted by Norck View Post
Use
pawn Code:
public killedplayer(playerid)
{
    SetPlayerHealth(playerid, 0.000);
    return 1;
}
Yea, and forward that too using:
pawn Code:
forward killedplayer(playerid);
Put it below your includes.
  Reply With Quote
Old 31/12/2011, 03:47 PM   #6
NeverKnow
Big Clucker
 
Join Date: Aug 2010
Posts: 123
Reputation: 1
Default Re: My timed kill command isn't working.

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 );
}
NeverKnow is offline   Reply With Quote
Old 31/12/2011, 03:48 PM   #7
FireCat
High-roller
 
FireCat's Avatar
 
Join Date: Jul 2010
Posts: 2,322
Reputation: 609
Default Re: My timed kill command isn't working.

Uhh
He should do SetTimerEx...
pawn Code:
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;
}
FireCat is offline   Reply With Quote
Old 31/12/2011, 03:49 PM   #8
NeverKnow
Big Clucker
 
Join Date: Aug 2010
Posts: 123
Reputation: 1
Default Re: My timed kill command isn't working.

All doing wrong just Pickup my Codes ))
NeverKnow is offline   Reply With Quote
Old 31/12/2011, 03:50 PM   #9
Norck
Huge Clucker
 
Norck's Avatar
 
Join Date: Aug 2008
Location: Ukraine, Simferopol
Posts: 388
Reputation: 43
Default Re: My timed kill command isn't working.

Quote:
Originally Posted by suhrab_mujeeb View Post
Yea, and forward that too using:
pawn Code:
forward killedplayer(playerid);
Put it below your includes.
Thanks for correcting me. I've edited my post.
__________________
Releases: fly.inc
Norck is offline   Reply With Quote
Old 31/12/2011, 04:05 PM   #10
PlayHard
Huge Clucker
 
PlayHard's Avatar
 
Join Date: Nov 2011
Location: In an apartment
Posts: 216
Reputation: 22
Default Re: My timed kill command isn't working.

@Everyone: Thanks a lot guys! I've done that but now I am having 2 warnings,

pawn Code:
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:

pawn Code:
SetTimer("killedplayer", 14000, false,"i",playerid);
PlayHard is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with /kill command ! Yaszine Help Archive 3 26/12/2010 05:59 PM
[Help] Kill command. [Aka]Dragonu Help Archive 7 01/12/2010 09:56 AM
Timed Mute Command Nightmare[TR] Help Archive 1 17/07/2010 08:58 PM
Car kill command Fedee! Help Archive 4 16/01/2010 01:40 PM
Any command kill you! Antonio [G-RP] Help Archive 24 08/08/2009 03:58 AM


All times are GMT. The time now is 07:42 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.