AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Where is the error? (https://forums.alliedmods.net/showthread.php?t=141280)

GalegO 10-21-2010 18:51

Where is the error?
 
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!

fysiks 10-21-2010 19:15

Re: Where is the error?
 
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?

GalegO 10-21-2010 19:30

Re: Where is the error?
 
I'm merging two plugins and fixing his bugs, so this is not a 100% my code...

Both plugins are bugged :( (edit) and abandoned

fysiks 10-21-2010 19:38

Re: Where is the error?
 
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.

GalegO 10-21-2010 19:50

Re: Where is the error?
 
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.

fysiks 10-21-2010 20:29

Re: Where is the error?
 
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.

Lulu the hero 10-21-2010 21:00

Re: Where is the error?
 
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 ]
:)

GalegO 10-26-2010 11:17

Re: Where is the error?
 
OK. Now I understand :) I'm a Headstrong rsrsrs...

I'm outta time right now, but will answer with the results later


All times are GMT -4. The time now is 10:19.

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