AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [solved] tag mismatch ? (https://forums.alliedmods.net/showthread.php?t=127094)

r14170 05-16-2010 16:57

[solved] tag mismatch ?
 
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 ?

Xellath 05-16-2010 17:10

Re: [solved] tag mismatch ?
 
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 }

r14170 05-16-2010 17:28

Re: [solved] tag mismatch ?
 
thanks

NiQu 05-16-2010 17:33

Re: [solved] tag mismatch ?
 
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:
    {
        
    }



fysiks 05-16-2010 19:39

Re: [solved] tag mismatch ?
 
Quote:

Originally Posted by NiQu (Post 1182655)
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.

SnoW 05-17-2010 10:54

Re: [solved] tag mismatch ?
 
The best way is to use if and else.

fysiks 05-17-2010 17:46

Re: [solved] tag mismatch ?
 
Quote:

Originally Posted by SnoW (Post 1183208)
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).

NiQu 05-17-2010 19:26

Re: [solved] tag mismatch ?
 
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.

SnoW 05-18-2010 08:01

Re: [solved] tag mismatch ?
 
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.

NiQu 05-18-2010 19:40

Re: [solved] tag mismatch ?
 
SnoW, you are so wrong.

He can still check if user is alive before doing the switch.


All times are GMT -4. The time now is 03:40.

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