Raised This Month: $ Target: $400
 0% 

Proper way to attach a value to a native


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 07-24-2010 , 19:20   Proper way to attach a value to a native
Reply With Quote #1

I'm playing around with a plugin that works sorta like a zombie infection mod where when players die they turn into zombies. Anyways, the teams switch at the end of the round and go to the other team (that they started on the round before). I created an array called g_pTeam[33], and I grab the value when they first join a team. After that, the mod changes their teams during the rounds, but at the end of the round, it gets their g_pTeam[id] value and changes it to the opposite team. Right now I get a couple players every round who do not swap right, I thought it was an issue with autobalance or limitteams, but they are both set to 0. I was just wondering if there was a more efficient way to do this.

Here is an example of the team swap.
Quote:
cs_set_user_team(player, g_pTeam[player] == CS_TEAM_T ? CS_TEAM_CT:CS_TEAM_T)
g_pTeam[player] = cs_get_user_team(player)
I also get an error when grabbing and setting the g_pTeam[id] value
Quote:
Warning: Tag mismatch on line 601
I was wondering how to set it to not get an error. I was thinking making it static or constant would, but that doesn't make sense to me. Thank you for any help.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 07-24-2010 , 19:27   Re: Proper way to attach a value to a native
Reply With Quote #2

To get rid of that tag mismatch you need to declare g_pTeam as CsTeams.

PHP Code:
new CsTeams:g_pTeam[33
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-24-2010 , 19:28   Re: Proper way to attach a value to a native
Reply With Quote #3

Show more code.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 07-24-2010 , 22:10   Re: Proper way to attach a value to a native
Reply With Quote #4

This is all the code that changes teams. It looks solid enough to me, but I know that I can't code for !%#^. Thank you very much for you help so far. I should've known the CsTeams: .

PHP Code:
public task_force_team_join(menu_msgid[], id
{
    if (
get_user_team(id))
        return

    static 
msg_block
    msg_block 
get_msg_block(menu_msgid[0])
    
set_msg_block(menu_msgid[0], BLOCK_SET)
    
engclient_cmd(id"jointeam""5")
    
engclient_cmd(id"joinclass""5")
    
set_msg_block(menu_msgid[0], msg_block)
    
    
g_pTeam[id] = cs_get_user_team(id)

PHP Code:
public logevent_round_end()
{
    new 
players[32], num
    get_players
(playersnum)
        
    new 
player
    
for (new 0numi++)
    {
        
player players[i]
        
cs_set_user_team(playerg_pTeam[player] == CS_TEAM_T CS_TEAM_CT:CS_TEAM_T)
        
g_pTeam[player] = cs_get_user_team(player)
    }
    
print_color(0"^x04%L"LANG_SERVER"TEAMS_SWAPPED")

    
    if (
task_exists(TASK_ROUND))
        
remove_task(TASK_ROUND)
    if (
task_exists(BUILD_TASK))
        
remove_task(BUILD_TASK)
        
    return 
PLUGIN_HANDLED

CT Death Event
PHP Code:
cs_set_user_team(g_victimcs_get_user_team(g_victim) == CS_TEAM_T CS_TEAM_CT:CS_TEAM_T
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 07-25-2010 , 05:48   Re: Proper way to attach a value to a native
Reply With Quote #5

PHP Code:
for( new 0numi++ )
        
cs_set_user_team( ( player players] ), ( g_pTeamplayer ] = ( g_pTeamplayer ] == CS_TEAM_T CS_TEAM_CT CS_TEAM_T ) ) ) 
SnoW is offline
Send a message via MSN to SnoW
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-25-2010 , 08:21   Re: Proper way to attach a value to a native
Reply With Quote #6

As a side note, you can replace :

PHP Code:
    if (task_exists(TASK_ROUND))
        
remove_task(TASK_ROUND)
    if (
task_exists(BUILD_TASK))
        
remove_task(BUILD_TASK
with

PHP Code:
        remove_task(TASK_ROUND)
        
remove_task(BUILD_TASK
because remove_task checks if the task exists.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 00:08.


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