Raised This Month: $ Target: $400
 0% 

[TUT] Enumerations (enum)


Post New Thread Reply   
 
Thread Tools Display Modes
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-06-2012 , 11:00   Re: [TUT] Enumerations (enum)
Reply With Quote #71

Quote:
Originally Posted by Bugsy View Post
You're just doing it wrong.
so....how do i do it?
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-06-2012 , 11:09   Re: [TUT] Enumerations (enum)
Reply With Quote #72

Quote:
Originally Posted by fysiks View Post
What does "bad results" mean?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-06-2012 , 11:17   Re: [TUT] Enumerations (enum)
Reply With Quote #73

It doesn't do anything. Like the enum isn't running to its proper case.

In another function i put a default case with a print statement to show it was there. And it went there 100% of the time. Leading me to believe either enums don't run properly through switch statements, or my enums don't have values, which wouldn't make any sense....

PHP Code:
public bkf_disablePowers(id)
{
    new 
PowerClass:pwr powers[id]
    
    switch(
pwr)
    {
        case 
PC_HEALTHremove_task(1)
        case 
PC_GRAVITY
        {
            new 
Float:serverGravity get_pcvar_float(g_pGravity)
            new 
Float:gravity = (0.55 800) / serverGravity
            set_user_gravity
(idgravity)
            
client_print(idprint_chat"Gravity should have been set in disablePowers")
        }
        default: 
client_print(idprint_chat"disablePowers default has been run.")
    }

Gravity is never set, task is never removed, and the print is always run
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 07-06-2012 at 11:18. Reason: added code
Liverwiz is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-06-2012 , 12:08   Re: [TUT] Enumerations (enum)
Reply With Quote #74

Instead of blaming the enum, blame your code. Did you try to debug ? Function is called ? What is the value of pwr ? etc. Add some debug print and see what happens.
__________________
Arkshine is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-06-2012 , 12:46   Re: [TUT] Enumerations (enum)
Reply With Quote #75

Quote:
Originally Posted by Arkshine View Post
Instead of blaming the enum, blame your code. Did you try to debug ? Function is called ? What is the value of pwr ? etc. Add some debug print and see what happens.
working on it, and still no answers. Not completely sure its the enum....just a really weird happening. print statements are getting me closer, though.

EDIT: It only works if i declare pwr as a static. Why? i have no idea. But....yeah.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 07-06-2012 at 12:58.
Liverwiz is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-06-2012 , 14:36   Re: [TUT] Enumerations (enum)
Reply With Quote #76

Quote:
Originally Posted by Liverwiz View Post
EDIT: It only works if i declare pwr as a static. Why? i have no idea. But....yeah.
New/Static makes no difference in the code you showed. Show your full code.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-06-2012 , 20:07   Re: [TUT] Enumerations (enum)
Reply With Quote #77

Quote:
Originally Posted by Exolent[jNr] View Post
New/Static makes no difference in the code you showed. Show your full code.
Attached. Its kinda big...

Mind you i got some things working since my last post. And its really messy from debugging. But it a few things still aren't working. (gravity at bkf_disablePowers specifically) but i'm still not sure yet if that's the core or this plugin. (which is an extension to an API)
Give Health also does not work. But that's for a different discussion entirely.

EDIT: i tried in another function bkf_setHud and it returns 0. I know this because i have a print in the calling function to say when it does. I am using PC_SILENT for this test. (i know PC_SILENT works because it is set in bkf_setPowers) My footsteps are silent.

MORE EDITING:
Quote:
PHP Code:
g_pGravity get_cvar_pointer("sv_gravity"
RAWFUL i found why gravity wasn't working....
But setHud is still a mystery.

EVENT MORE EDITING: Well....setHud doesn't work because you can't change the string sent by a forward. It just cuts out execution and returns. I'm learning so much the hard way...i want to cry.
Attached Files
File Type: sma Get Plugin or Get Source (liver_bkpowers.sma - 463 views - 7.0 KB)
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 07-07-2012 at 01:35. Reason: Updated code
Liverwiz is offline
Mati_
Member
Join Date: Sep 2010
Old 12-17-2012 , 20:48   Re: [TUT] Enumerations (enum)
Reply With Quote #78

Is it possible to get the numerical value of an enum (without getting a tag mismatch warning)?
Mati_ is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-17-2012 , 21:11   Re: [TUT] Enumerations (enum)
Reply With Quote #79

Quote:
Originally Posted by Mati_ View Post
Is it possible to get the numerical value of an enum (without getting a tag mismatch warning)?
Prefix the variable with "_:" if you are assigning it to a variable without any tag.
__________________
fysiks is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 12-18-2012 , 14:52   Re: [TUT] Enumerations (enum)
Reply With Quote #80

Quote:
Originally Posted by fysiks View Post
Prefix the variable with "_:" if you are assigning it to a variable without any tag.
What "_:" means ?
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
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 08:03.


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