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

convert enum to number and back. right method


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
karaulov
Senior Member
Join Date: Jul 2018
Old 12-14-2021 , 03:02   convert enum to number and back. right method
Reply With Quote #1

How to convert TeamName to integer and back ?

new integer1 = TEAM_CT;

new TeamName:team1 = 2;

tag mismatch
karaulov is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-14-2021 , 03:50   Re: convert enum to number and back. right method
Reply With Quote #2

Where is your enum?

And what do you mean with that title? O_o?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-14-2021 at 03:51.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 12-14-2021 , 04:24   Re: convert enum to number and back. right method
Reply With Quote #3

Huh ?

Simple method to replace team name:
PHP Code:
new const szTeamName[ ][ ] = { "Unassigned",  "Terrorist""Counter-Terrorist""Spectator" }

public 
Ham_Spawnid )
{
    new 
iTeam get_user_teamid );
    
client_printidprint_chat"You team is: %s"szTeamNameiTeam ] )

__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
karaulov
Senior Member
Join Date: Jul 2018
Old 12-14-2021 , 05:13   Re: convert enum to number and back. right method
Reply With Quote #4

No need just cast between enums and integers.

new integer1 = TEAM_CT;
new TeamName:team1 = 2;
tag mismatch

How to convert enum to integer and back without tag mismatch))))

Last edited by karaulov; 12-14-2021 at 05:16.
karaulov is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-14-2021 , 05:20   Re: convert enum to number and back. right method
Reply With Quote #5

Code:
new integer1 = _:TEAM_CT new TeamName:team1 = TeamName:2

The variable tag must be the same as the value tag.

_: is used as a blank tag.
__________________

Last edited by OciXCrom; 12-14-2021 at 14:12.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 12-14-2021 , 05:37   Re: convert enum to number and back. right method
Reply With Quote #6

new integer1 = _:TEAM_CT;

new TeamName:team1 = TeamName:2;
jimaway is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-14-2021 , 10:14   Re: convert enum to number and back. right method
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
new integer1 = _:TEAM_CT
new TeamName:team1 = TeamName:2

The variable tag must be the same as the value tag.

_: is used as a blank tag.
I think it is more intuitive to explain _: as detagging(removing the tag) than it being a blank tag.

Also, tagging/detagging is only needes for strong tags(starting with a upper case letter). For weak tags nothing needs to be done.
__________________

Last edited by HamletEagle; 12-14-2021 at 10:17.
HamletEagle 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 22:55.


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