Raised This Month: $32 Target: $400
 8% 

Tag mismatch between cs_get_user_team() and write_short()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
frio
Junior Member
Join Date: May 2020
Old 05-26-2020 , 03:43   Tag mismatch between cs_get_user_team() and write_short()
Reply With Quote #1

I'm trying to change the player's frags and deaths on the scoreboard, and I'm getting a tag mismatch warning for the team variable.

PHP Code:
new playerfragsdeathsCsTeams:team
player 
/* this will be the client id */
frags 10
deaths 
5
team 
cs_get_user_team(player)
set_user_frags(playerfrags)
cs_set_user_deaths(playerdeaths)
message_begin(MSG_ALLget_user_msgid("ScoreInfo"))
write_byte(player)
write_short(frags)
write_short(deaths)
write_short(0)
write_short(team)
message_end() 
From what I can tell, write_short() needs an integer, but team variable has tag "CsTeams".

I know I can fix this in one of two ways:
  • Use get_user_team() instead of cs_get_user_team(), but I've read this is unreliable in certain situations.
  • Detag team like so:
    Code:
    write_short(_:team)
    but isn't this bad practice?

What should I do?
frio is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 05-26-2020 , 04:40   Re: Tag mismatch between cs_get_user_team() and write_short()
Reply With Quote #2

If you just want to change the score, use HamSandwich.

PHP Code:
set_pdata_int(iAttacker711deaths);
ExecuteHamB(Ham_AddPointsiAttackeraddFragstrue); 
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-26-2020 , 23:25   Re: Tag mismatch between cs_get_user_team() and write_short()
Reply With Quote #3

write_short() is used to write a short integer, it doesn't know how you're going to use every single variable that it will be used with. After all, most tags are for convenience in Pawn (e.g. to find mistakes at compile time), they do not actually define a data type like in strictly typed languages.

So, no, de-tagging a variable is not bad practice when done for the proper purposes (like in this case). The act of de-tagging the variable is you the coder saying, yes, this is where I need to use this variable.
__________________
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 17:14.


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