AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Tag mismatch between cs_get_user_team() and write_short() (https://forums.alliedmods.net/showthread.php?t=324745)

frio 05-26-2020 03:43

Tag mismatch between cs_get_user_team() and write_short()
 
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?

+ARUKARI- 05-26-2020 04:40

Re: Tag mismatch between cs_get_user_team() and write_short()
 
If you just want to change the score, use HamSandwich.

PHP Code:

set_pdata_int(iAttacker711deaths);
ExecuteHamB(Ham_AddPointsiAttackeraddFragstrue); 


fysiks 05-26-2020 23:25

Re: Tag mismatch between cs_get_user_team() and write_short()
 
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.


All times are GMT -4. The time now is 21:05.

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