Raised This Month: $344 Target: $400
 86%   Almost there!

Execute Command Once every spawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NickischLP
Senior Member
Join Date: Jun 2013
Location: Germany
Old 05-11-2019 , 21:34   Execute Command Once every spawn
Reply With Quote #1

Hello,

I am trying to execute a command on every respawn on time.
But the command is in a loop, I couldnt figure out how to stop it.
PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_spawn"SpawnEventEventHookMode);
}

public 
Action:SpawnEvent(Handle event,char[] name,bool dontBroadcast)
{
    
int iClient_id GetEventInt(event"userid");
    
int iClient GetClientOfUserId(iClient_id);
    if(
IsClientInGame(iClient) && IsPlayerAlive(iClient) && TFTeam_Red)
    {
        
ServerCommand("sm_titan \"%N\" "iClient);
    }
    else
    {
        
PrintToServer("NOT WORKING");
    }

__________________

Last edited by NickischLP; 05-11-2019 at 21:35.
NickischLP is offline
Send a message via Skype™ to NickischLP
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 05-11-2019 , 22:21   Re: Execute Command Once every spawn
Reply With Quote #2

Quote:
Originally Posted by NickischLP View Post
Hello,

I am trying to execute a command on every respawn on time.
But the command is in a loop, I couldnt figure out how to stop it.
PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_spawn"SpawnEventEventHookMode);
}

public 
Action:SpawnEvent(Handle event,char[] name,bool dontBroadcast)
{
    
int iClient_id GetEventInt(event"userid");
    
int iClient GetClientOfUserId(iClient_id);
    if(
IsClientInGame(iClient) && IsPlayerAlive(iClient) && TFTeam_Red)
    {
        
ServerCommand("sm_titan \"%N\" "iClient);
    }
    else
    {
        
PrintToServer("NOT WORKING");
    }

what do u mean by the command is in loop?
__________________
8guawong is offline
NickischLP
Senior Member
Join Date: Jun 2013
Location: Germany
Old 05-12-2019 , 06:24   Re: Execute Command Once every spawn
Reply With Quote #3

I got it fixed
__________________

Last edited by NickischLP; 05-12-2019 at 06:37.
NickischLP is offline
Send a message via Skype™ to NickischLP
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-12-2019 , 11:01   Re: Execute Command Once every spawn
Reply With Quote #4

??

PHP Code:
    if(IsClientInGame(iClient) && IsPlayerAlive(iClient) && TFTeam_Red)

>>>

PHP Code:
    if(IsClientInGame(iClient) && IsPlayerAlive(iClient) && GetClientTeam(iClient) == TFTeam_Red)



Also to help others how did you fix?
__________________
Silvers 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 07:37.


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