Raised This Month: $32 Target: $400
 8% 

Function only work once?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 11-24-2014 , 09:21   Function only work once?
Reply With Quote #1

PHP Code:
public OnPluginStart()
{
    
HookEvent("tank_killed"Event_TankDeath);
}

stock RestoreHealth(client)
{
    
CheatCommand(client"sm_heal""@me");
}

public 
Action:Event_TankDeath(Handle:event, const String:strName[], bool:DontBroadcast)
{
    for (new 
1<= MaxClientsi++)
    {
        if (
IsValidEntity(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == && 0) {
            
RestoreHealth(i);
        }
    }
}

stock CheatCommand(clientString:command[], String:arguments[]="")
{
    new 
userflags GetUserFlagBits(client);
    
SetUserFlagBits(clientADMFLAG_ROOT);
    new 
flags GetCommandFlags(command);
    
SetCommandFlags(commandflags & ~FCVAR_CHEAT);
    
FakeClientCommand(client"%s %s"commandarguments);
    
SetCommandFlags(commandflags);
    
SetUserFlagBits(clientuserflags);

My problem is this function only work first time when trigger it, after it trigger won't work anymore. have to reload plugin or wait for map change, will work once again, any help?

P.S:I'm very sure "sm_heal xxx" function don't have any problem

Last edited by gilmon; 11-24-2014 at 09:22.
gilmon is offline
Send a message via MSN to gilmon
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 11-24-2014 , 10:48   Re: Function only work once?
Reply With Quote #2

A. What's the goal of the plugin? Looks like It's to heal all players on the server back up to full health? I'm assuming since It's L4D (assuming) that you only want the survivors to heal back up to full health because of the team check?

B. Where does the command 'sm_heal' come from? Which plugin(s)?


You could also just use these:
https://sm.alliedmods.net/api/index....d=show&id=819&
https://sm.alliedmods.net/api/index....d=show&id=423&

Code:
new health = GetClientHealth(client);
SetEntityHealth(client, health + ADD);
Drixevel is offline
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 12-09-2014 , 16:10   Re: Function only work once?
Reply With Quote #3

Sorry for the delay about this topic, it's already fixed just because a little bug.whatever, thanks!
And the "sm_heal" command is come from this

Last edited by gilmon; 12-09-2014 at 16:10.
gilmon is offline
Send a message via MSN to gilmon
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 01-24-2020 , 12:55   Re: Function only work once?
Reply With Quote #4

Sorry to up this post but i have the same problem with HookEvent "tank_killed" who never trigger in versus. Did you find a solution ?
JLmelenchon is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 01-27-2020 , 04:49   Re: Function only work once?
Reply With Quote #5

try "player_death" or OnClientDisconnect()

Example: [inc] Left4dragokas

P.S. It's better create new thread for such old topics.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
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

Forum Jump


All times are GMT -4. The time now is 03:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode