AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Teamscore event (https://forums.alliedmods.net/showthread.php?t=221962)

connoisseur 07-28-2013 13:21

[Help] Teamscore event
 
Code:
public Event_TeamScore() {     new szTeam[2];     read_argv(1, szTeam, charsmax(szTeam));     if (szTeam[0] == 'T')     {         g_iTsScore = read_data(2);      }     else     {         g_iCTsScore = read_data(2);     }     if(g_iCTsScore == 8)     {         match_over(1);     }     else if (g_iTsScore == 8)     {         match_over(2);     }     return PLUGIN_HANDLED }   match_over(num) {     new szName[32]     get_user_name(g_qid[num],szName,31)     //g_qid[1] = ct player id, g_qid[2] = t player id     client_print(0,print_chat,"%s has won !!", szName)     client_print(0,print_chat,"%s has won !!", szName) }
When I was testing this, I was in T and even when CT player won 8 rounds, the printing showed "<my nick> has won !!"

YamiKaitou 07-28-2013 13:47

Re: [Help] Teamscore event
 
Where are you assigning g_id a value?

connoisseur 07-29-2013 12:53

Re: [Help] Teamscore event
 
Code:
//plugin_init register_clcmd("say /ready", "cmdReady") //function public cmdReady(id) {     if(g_qflag[id])     {         client_print(id,print_chat,"Already in the queue.")         return PLUGIN_CONTINUE     }     g_qflag[id] = 1     g_qnum++     g_qid[g_i] = id     //storing indexes in queue numbers     g_i++     client_print(id,print_chat,"Placed in the queue at %d position", g_qnum)     return PLUGIN_HANDLED }

YamiKaitou 07-29-2013 13:10

Re: [Help] Teamscore event
 
g_id is not found in that block of code

connoisseur 07-29-2013 13:16

Re: [Help] Teamscore event
 
Quote:

Originally Posted by YamiKaitou (Post 2001512)
g_id is not found in that block of code

Sorry that was a typo in the first post.. edited.
It was g_qid only.

YamiKaitou 07-29-2013 14:34

Re: [Help] Teamscore event
 
Then you set your system up incorrectly as as you are passing 1 or 2 as the winner, so only 2nd or 3rd person ready will ever be shown as the winner, even if they didn't win.

MPD 07-29-2013 14:52

Re: [Help] Teamscore event
 
PHP Code:

match_over(num)
{
    new 
szName[32]
    
get_user_name(g_qid[num],szName,31)     //g_qid[1] = ct player id, g_qid[2] = t player id
    
client_print(0,print_chat,"%s has won !!"szName)
    
client_print(0,print_chat,"%s has won !!"szName)


What should this show? Team name? Names of people who are in winners team?

ConnorMcLeod 07-30-2013 01:25

Re: [Help] Teamscore event
 
TeamScore is always sent twice, the first time CT Score is passed, the second time Ts.
So you have to wait for Ts score in order to perform your checks.
Also, don't return PLUGIN_HANDLED in an event callback, it has no effect.
just use return with no value, or use return PLUGIN_CONTINUE, in your code, no return was needed, i've added one because of the first thing i told you.

PHP Code:

public Event_TeamScore()
{
    new 
szTeam[2];
    
read_argv(1szTeamcharsmax(szTeam));
    if (
szTeam[0] == 'T')
    {
        
g_iTsScore read_data(2);  
    }
    else
    {
        
g_iCTsScore read_data(2);
        return; 
// CT score comes before T score
    
}

    if(
g_iCTsScore == 8)
    {
        
match_over(1);
    }
    else if (
g_iTsScore == 8)
    {
        
match_over(2);
    }




All times are GMT -4. The time now is 15:51.

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