Raised This Month: $51 Target: $400
 12% 

Solved Tag Mismatch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hellmonja
Senior Member
Join Date: Oct 2015
Old 01-03-2017 , 14:57   Tag Mismatch
Reply With Quote #1

What am I doing wrong???
PHP Code:
public Event_Death()
{
    new 
id read_data(1);
    new 
team cs_get_user_team(id);

It's giving a warning on the fourth line where I'm trying to find which team the killer belongs...
__________________

Last edited by hellmonja; 06-25-2017 at 04:10. Reason: Solved...
hellmonja is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-03-2017 , 15:11   Re: [HELP] Tag Mismatch
Reply With Quote #2

new CsTeams:team
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
hellmonja
Senior Member
Join Date: Oct 2015
Old 01-03-2017 , 15:18   Re: [HELP] Tag Mismatch
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
new CsTeams:team
Hey thanks! It worked. Just curious though, if it doesn't simply return a number, what does this return? A string?...
__________________
hellmonja is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-03-2017 , 15:25   Re: [HELP] Tag Mismatch
Reply With Quote #4

You can try it, just for see what it return.
PHP Code:
new CsTeams:team cs_get_user_team(id)

console_print(id,"%s %d",team,team
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 01-03-2017 at 15:26.
EFFx is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 01-03-2017 , 15:32   Re: [HELP] Tag Mismatch
Reply With Quote #5

Okay, so I'm trying to use the team variable as a num. So far it's giving me the warning when I do so. Should I convert it to num, and how? str_to_num didn't help...
__________________
hellmonja is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-03-2017 , 15:36   Re: [HELP] Tag Mismatch
Reply With Quote #6

Just do what OciXCrom said to you.

PHP Code:
new team cs_get_user_team(id
->

PHP Code:
new CsTeams:team cs_get_user_team(id
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 01-03-2017 , 15:42   Re: [HELP] Tag Mismatch
Reply With Quote #7

Quote:
Originally Posted by EFFx View Post
Just do what OciXCrom said to you.
But then:
PHP Code:
public Event_Death()
{
    new 
id read_data(1);
    new 
CsTeams:team cs_get_user_team(id);

    if(
id == victim)
        return
    else
        
Team_Point(teamPTS_KILL);

Getting the same warning but on the last line now...
__________________
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-03-2017 , 15:43   Re: [HELP] Tag Mismatch
Reply With Quote #8

Quote:
Originally Posted by hellmonja View Post
Okay, so I'm trying to use the team variable as a num. So far it's giving me the warning when I do so. Should I convert it to num, and how? str_to_num didn't help...
:facepalm:
People, start using the API page, it can help a lot. http://amxmodx.org/api/cstrike/cs_get_user_team
Quote:
Return

Team id
So a number. Variable can have tags, that's not unusual(Float: is a tag too, and the var is still a number).


Quote:
enum CsTeams
{
CS_TEAM_UNASSIGNED = 0,
CS_TEAM_T = 1,
CS_TEAM_CT = 2,
CS_TEAM_SPECTATOR = 3,
};

native CsTeams:cs_get_user_team(index, &{CsInternalModel,_}:model = CS_DONTCHANGE);
Native is tagged with CsTeams enum, that's why you need to tag your variable like that too.

Edit: About last warning, you need to tag the param from your function with CsTeams too.
__________________

Last edited by HamletEagle; 01-03-2017 at 15:44.
HamletEagle is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-03-2017 , 19:32   Re: [HELP] Tag Mismatch
Reply With Quote #9

Or de-tag native's return value, seems like it will work better for you.
PHP Code:
new team _:cs_get_user_team(id
Read about tags in Pawn, there's a tutorial around here.
klippy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-03-2017 , 20:44   Re: [HELP] Tag Mismatch
Reply With Quote #10

Quote:
Originally Posted by KliPPy View Post
Or de-tag native's return value, seems like it will work better for you.
PHP Code:
new team _:cs_get_user_team(id
I would recommend not doing this. There is a tag for a reason. It allows you to use contextual values which creates self-documenting code, so that instead of:

Code:
if( team == 1 )
you would do:

Code:
if( team == CS_TEAM_CT )
Notice that there is an error in this example but if I only used the tagged values as defined in the CsTeams enum, I wouldn't have made this mistake (without getting a tag mismatch warning; this is one reason why the tag mismatch warning is useful).
__________________

Last edited by fysiks; 01-03-2017 at 20:47.
fysiks 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 04:29.


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