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

If executed, don't execute other


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Official_Cracky
Junior Member
Join Date: May 2014
Location: France
Old 05-17-2014 , 03:26   If executed, don't execute other
Reply With Quote #1

I want if my Part 1 is executed, the Part 2 will no execute during the round when a player die, and the Part 1 wiil not execute a second time. It's possible ?
Code:
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
// ********** PART 1 **********
    if (GetClientTeam(victim) == 3)
        PrintToChatAll("First blood by T Team")
// **************************
//
// ********** PART 2 **********
    if(GetClientTeam(victim) == 2)
        PrintToChatAll("First blood by CT Team")
// **************************
Official_Cracky is offline
Doodil
Senior Member
Join Date: Mar 2012
Old 05-17-2014 , 04:45   Re: If executed, don't execute other
Reply With Quote #2

Create a global bool variable that gets set to false on round start and to true once part 1 or part 2 happened. Before executing your code check if the global variable is true or false and act accordingly
Doodil is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 05-17-2014 , 05:30   Re: If executed, don't execute other
Reply With Quote #3

Quote:
Originally Posted by Official_Cracky View Post
I want if my Part 1 is executed, the Part 2 will no execute during the round when a player die, and the Part 1 wiil not execute a second time. It's possible ?
Code:
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
// ********** PART 1 **********
    if (GetClientTeam(victim) == 3)
        PrintToChatAll("First blood by T Team")
// **************************
//
// ********** PART 2 **********
    if(GetClientTeam(victim) == 2)
        PrintToChatAll("First blood by CT Team")
// **************************
Change the part to 'if' statement to 'else if' and add in a bool that sets to true on 1st player death every round and just check if it's not true on this event then reset it on round start.

- Jack
Drixevel is offline
Official_Cracky
Junior Member
Join Date: May 2014
Location: France
Old 05-17-2014 , 07:49   Re: If executed, don't execute other
Reply With Quote #4

Can you help me more for the bool please ? I'm a beginner
Official_Cracky is offline
joac1144
Senior Member
Join Date: Dec 2012
Location: Copenhagen, Denmark
Old 05-17-2014 , 08:53   Re: If executed, don't execute other
Reply With Quote #5

Quote:
Originally Posted by Official_Cracky View Post
Can you help me more for the bool please ? I'm a beginner
I think this should work:
Code:
new bool:g_bCheckBool;

public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    g_bCheckBool = false;
}

public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new victim = GetClientOfUserId(GetEventInt(event, "userid"));
    
    if(!g_bCheckBool)
    {
        // ********** PART 1 **********
        if (GetClientTeam(victim) == 3)
        {
            PrintToChatAll("First blood by T Team")
            g_bCheckBool = true;
        }
        // **************************
        
        // ********** PART 2 **********
        else if(GetClientTeam(victim) == 2)
        {
            PrintToChatAll("First blood by CT Team")
            g_bCheckBool = true;
        }
        // **************************
    }
}
__________________
joac1144 is offline
Official_Cracky
Junior Member
Join Date: May 2014
Location: France
Old 05-17-2014 , 10:38   Re: If executed, don't execute other
Reply With Quote #6

It doesn't work. After the first round, the chat sentence is not printed
Official_Cracky is offline
joac1144
Senior Member
Join Date: Dec 2012
Location: Copenhagen, Denmark
Old 05-17-2014 , 11:38   Re: If executed, don't execute other
Reply With Quote #7

Quote:
Originally Posted by Official_Cracky View Post
It doesn't work. After the first round, the chat sentence is not printed
Did you hook round_start?
PHP Code:
public OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);

__________________
joac1144 is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 05-17-2014 , 15:43   Re: If executed, don't execute other
Reply With Quote #8

Those tutorials might be handy for you in future :
SourceMod Scripting API
SourceMod Scripting
__________________
...
Oshizu is offline
Official_Cracky
Junior Member
Join Date: May 2014
Location: France
Old 05-18-2014 , 03:15   Re: If executed, don't execute other
Reply With Quote #9

Thanks all, it's working now
Official_Cracky 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 04:19.


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