Raised This Month: $ Target: $400
 0% 

The type of a variable!!??


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
xbennY
New Member
Join Date: Jan 2014
Old 07-11-2014 , 16:51   Re: The type of a variable!!??
Reply With Quote #3

I want to make ONE function to reset the data in a enum separated, this enum have a lot of type variables.

Example:

PHP Code:
enum eAccount
{
    
bool:Alive,
    
Kills
};


new 
gPlayer[33][eAccount]; 

*If i want to reset the data from "Alive": Reset_gPlayer(Alive); then the function resets that variable(Alive) in all "33"(32) gPlayers
**If i want to reset the data from "Kills": Reset_gPlayer(Kills); then the function resets that variable(Kills) in all "33"(32) gPlayers

Theoretically the function would look something like this:

PHP Code:
Reset_gPlayer(var)
{
    for(new 
033; ++i)
        
gPlayer[i][var] = 0;    

This would work perfectly in other programming languages ​​but it does not works in Pawn because when the variable is Boolean he can not take the value 0 or 1, only the values ​​true and false.
If it had some function that returns the type of the variable, I could just do something like this:

PHP Code:
Reset_gPlayer(var)
{
    for(new 
033; ++i)
        if(
isBool(var))
            
gPlayer[i][var] = false;
        else
            
gPlayer[i][var] = 0;    

I want this to automate my code and makes it cleaner. ---> To not put a lot of "for's" in my project.
I hope you understood my question now! Thanks...!

Last edited by xbennY; 07-11-2014 at 16:54.
xbennY is offline
 



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 21:10.


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