Raised This Month: $ Target: $400
 0% 

[solved] tag mismatch ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r14170
Veteran Member
Join Date: Dec 2009
Old 05-16-2010 , 16:57   [solved] tag mismatch ?
Reply With Quote #1

Code:
1. if (cs_get_user_team(id) == 1) { 
2.     cs_set_user_model(id, "hns_t")
3. } 
4. else if(cs_get_user_team(id) == 2) { 
5.     cs_set_user_model(id, "hns_ct") 
6. }
when i compile it says
tag mismatch on line 1
tag mismatch on line 4

(this is not the whole plugin)


EDIT: I replace it with CS_TEAM_T and CS_TEAM_CT and it works

what i need to do ?
r14170 is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 05-16-2010 , 17:10   Re: [solved] tag mismatch ?
Reply With Quote #2

Already solved but, just to tell others: cs_get_user_team() returns a tagged value - such as CS_TEAM_T (see cstrike.inc for other values in the "class").

Code:
new CsTeams:iTeam = cs_get_user_team( iPlayer ); // iPlayer = index of a player // iTeam is now.. lets say.. CS_TEAM_CT (2) // this means you cannot check it like this: if( iTeam == 2 ) {     // code } // you need to check it like this: if( iTeam == CS_TEAM_CT ) {     // code }

That is how you check it - unless you de-tag iTeam / cs_get_user_team like this:

Code:
if( _:cs_get_user_team( iPlayer ) == 2 ) {     // iPlayer is a CT } // or the other way around: if( cs_get_user_team( iPlayer ) == CsTeams:2 ) // tagged 2 means CS_TEAM_CT {     // iPlayer is a CT }
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
r14170
Veteran Member
Join Date: Dec 2009
Old 05-16-2010 , 17:28   Re: [solved] tag mismatch ?
Reply With Quote #3

thanks
r14170 is offline
NiQu
Veteran Member
Join Date: Nov 2009
Old 05-16-2010 , 17:33   Re: [solved] tag mismatch ?
Reply With Quote #4

I know its solved but isnt it better to use a switch?

PHP Code:
switch(cs_get_user_team(id) ) 
{
    case 
CS_TEAM_T:
    {
        
    }
    case 
CS_TEAM_CT:
    {
        
    }

__________________
My Projects
  • RoTAPI V0.0.1 ------- Private
    • Progress - [||||||||||]
  • CashMod V0.0.6 ----- Public
    • Progress - [||||||||||]
  • CashMod V0.0.7 ----- Public
    • Progress - [||||||||||]
NiQu is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-16-2010 , 19:39   Re: [solved] tag mismatch ?
Reply With Quote #5

Quote:
Originally Posted by NiQu View Post
I know its solved but isnt it better to use a switch?
It depends on how you are using it and if there is more than once case. In the code that was posted by the OP it would be better to use a switch.
__________________
fysiks is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 05-17-2010 , 10:54   Re: [solved] tag mismatch ?
Reply With Quote #6

The best way is to use if and else.
SnoW is offline
Send a message via MSN to SnoW
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-17-2010 , 17:46   Re: [solved] tag mismatch ?
Reply With Quote #7

Quote:
Originally Posted by SnoW View Post
The best way is to use if and else.
No, it's not. That would be true if cs_get_user_team() had only two results (it has 4 I believe).
__________________
fysiks is offline
NiQu
Veteran Member
Join Date: Nov 2009
Old 05-17-2010 , 19:26   Re: [solved] tag mismatch ?
Reply With Quote #8

Agreed with fysiks,
i know that cs_get_user_team has 4 results, if you only want to check 1 result use an if. If you want to check more then 1 result (1, 2, 3 or 4 results) you should use a switch.
__________________
My Projects
  • RoTAPI V0.0.1 ------- Private
    • Progress - [||||||||||]
  • CashMod V0.0.6 ----- Public
    • Progress - [||||||||||]
  • CashMod V0.0.7 ----- Public
    • Progress - [||||||||||]
NiQu is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 05-18-2010 , 08:01   Re: [solved] tag mismatch ?
Reply With Quote #9

It doesn't matter how many return values the native has. He's setting a model and is first checking that the player is alive. He is also not running a "be alive as spectator" mod so else if should be used.

Last edited by SnoW; 05-18-2010 at 08:04.
SnoW is offline
Send a message via MSN to SnoW
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-18-2010 , 19:58   Re: [solved] tag mismatch ?
Reply With Quote #10

Quote:
Originally Posted by SnoW View Post
It doesn't matter how many return values the native has. He's setting a model and is first checking that the player is alive. He is also not running a "be alive as spectator" mod so else if should be used.
Nowhere in this thread is there anything related to if a player is alive.
So what are you even talking about?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 03:40.


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