Raised This Month: $ Target: $400
 0% 

Where is the error?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GalegO
Member
Join Date: May 2010
Location: Brazil
Old 10-21-2010 , 18:51   Where is the error?
Reply With Quote #1

Guys, I have this part of code:

PHP Code:

public event_round_end()
{
    if(
get_cvar_num("sv_thpop") == 0)
    {
        return 
PLUGIN_CONTINUE
    
}
    
    if(
firstround == 1)
    {
        new 
playerTplayersT[32], playersCT[32], numTnumCT
        get_players
(playersTnumT"che""TERRORIST")
        
        for(new 
0numTi++)
        {
            
playerT playersT[i]
            if (!
is_user_connected(playerT))
              continue;
            
cs_set_user_team(playerTCS_TEAM_CT)
        }
        
        
get_players(playersCTnumCT"che""CT")        
        
HiddenID random(numCT)
        
        if (
is_user_alive(HiddenID) && is_user_connected(HiddenID))
        {        
            
cs_set_user_team(playersCT[HiddenID], CS_TEAM_T)
            
firstround 0
        
} else
        {
            
client_print(0print_center"Nao Tem HIDDEN")
        }
    }else
    {
        if(
HiddenID == solo || HiddenID == 0)
        {
            new 
playersCT[32], numCT
            get_players
(playersCTnumCT"che""CT")
            
HiddenID random(numCT)
            
            if (
is_user_alive(HiddenID) && is_user_connected(HiddenID))
            {        
                
cs_set_user_team(playersCT[HiddenID], CS_TEAM_T)
                
cs_set_user_team(soloCS_TEAM_CT)
            }
        }else
        {
            
cs_set_user_team(HiddenIDCS_TEAM_T)
            
cs_set_user_team(soloCS_TEAM_CT)
        }
    }

    new 
iplayers[32], count
    get_players
(playerscount)
    
    for (
0counti++)
    {
        
set_user_godmode(players[i], 1)
    }
    
    new 
name[32]
    
get_user_info(HiddenID"name"name31)
    if(
get_cvar_num("sv_thpop") == )
    {
        
client_print(0print_chat"%L %L "LANG_PLAYER"MSG_TAG"LANG_PLAYER"MSG_POPCORN_NEW"name)
        
format(hpTaskMessage256"%L"HiddenID"MSG_POPCORN_YOU_RESPAWN")
    } else
    {
        
client_print(0print_chat"%L %L "LANG_PLAYER"MSG_TAG"LANG_PLAYER"MSG_HIDDEN_NEW"name)
        
hpTaskTicks 15
        format
(hpTaskMessage256"%L"HiddenID"MSG_HIDDEN_YOU_RESPAWN")
    }
    
    return 
PLUGIN_CONTINUE

But in the conditions "firstround == 1" and "HiddenID == 0" the code never catch the HiddenID.

Where I mistake?

Thanks!

Last edited by GalegO; 10-21-2010 at 19:51.
GalegO is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-21-2010 , 19:15   Re: Where is the error?
Reply With Quote #2

HiddenID is not an id of a player. It is an index that you use in playersCT[] to get the id of the player.

Code:
a_players_id = playersCT[HiddenID]
is_user_connected(a_players_id)
etc.
Also, you can replace random_num(0, numCT-1) with random(numCT).

EDIT: I see that you did do it correctly in some places . . . did you copy paste this stuff?
__________________

Last edited by fysiks; 10-21-2010 at 19:18.
fysiks is offline
GalegO
Member
Join Date: May 2010
Location: Brazil
Old 10-21-2010 , 19:30   Re: Where is the error?
Reply With Quote #3

I'm merging two plugins and fixing his bugs, so this is not a 100% my code...

Both plugins are bugged (edit) and abandoned
GalegO is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-21-2010 , 19:38   Re: Where is the error?
Reply With Quote #4

It will probably be much harder than you think if you're not sure about what you are doing. FYI.

Might be easier to start over instead of copy pasting code together.
__________________
fysiks is offline
GalegO
Member
Join Date: May 2010
Location: Brazil
Old 10-21-2010 , 19:50   Re: Where is the error?
Reply With Quote #5

I know. But I am a systems analyst and I'm used to read codes. I am two weeks working on this mod and can say that I only have 3 bugs to finish.

This thread is one.

When I launch it, I know I'll have to make many improvements, but I think the hardest part is finishing.

I'm starting with scripting, but I'm reading a lot and I think I did a great evolution

I could not understand what you meant by your above code.

I updated the first post with the all function.
GalegO is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-21-2010 , 20:29   Re: Where is the error?
Reply With Quote #6

What I said was the variable HiddenID means absolutely nothing when used alone. The only way you can make it have any actual meaning is to use it as

playersCT[HiddenID]

HiddenID is not a player ID! playersCT[HiddenID] is a player ID. So, is_user_alive(HiddenID) is meaningless.
__________________
fysiks is offline
Lulu the hero
Senior Member
Join Date: Oct 2009
Location: Budapest, Hungary
Old 10-21-2010 , 21:00   Re: Where is the error?
Reply With Quote #7

fysiks' words in other words: ( I know, echo... )
[ echo source="fysiks" ]
playersCT is an array, which holds player IDs.
so there are lots of player IDs in the array, thus if you need one ID, you need to index the array. You could say, I would like the 1st element of the array by this:
Code:
playersCT[0]
or the 5th element:
Code:
playersCT[4]
You store the index number in HiddenID.
To get the 1st element, the method is below:
Code:
HiddenID=0;
playersCT[HiddenID];
So the HiddenID is an index of an array.

[ end of echo ]
Lulu the hero is offline
GalegO
Member
Join Date: May 2010
Location: Brazil
Old 10-26-2010 , 11:17   Re: Where is the error?
Reply With Quote #8

OK. Now I understand I'm a Headstrong rsrsrs...

I'm outta time right now, but will answer with the results later
GalegO is offline
Reply



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 10:19.


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