AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why doesn't (https://forums.alliedmods.net/showthread.php?t=11368)

NiGHTFiRE 03-17-2005 13:24

Why doesn't
 
Hello
I'm trying to learn some small now and I have made a little stupid plugin just to learn but I can't get it to work :oops:
Here is the code, please can anyone say what I have done wrong and dont just say bla bla, please show me with code so I know the next time.

Code:
#include <amxmodx> #include <fun>   public plugin_init() {   regester_plugin("God in Server", "1.0", "NiGHTFiRE")   regester_cvar("amx_god")     }     public client_putinserver(id)  {      if (get_cvar_num("amx_god") > 0)      {           set_user_godmode(id, get_cvar_num("amx_god"))           } else {           set_user_godmode(id, get_cvar_num("mp_god"))                    } }

Twilight Suzuka 03-17-2005 13:33

Quote:

#include <amxmodx>
#include <fun>

public plugin_init()
{

regester_plugin("God in Server", "1.0", "NiGHTFiRE")
regester_cvar("amx_god")

}

public client_putinserver(id)
{
if (get_cvar_num("amx_god") > 0)
{
set_user_godmode(id, get_cvar_num("amx_god"))
} else {
set_user_godmode(id, get_cvar_num("mp_god"))

}
}
Where to begin.... first off, there is no "mp_god" cvar. Second off, your else is in the wrong indent, which is not too bad, but still pretty stupid.

Third, you spelled "register" "regester"
Fourth, you did not give the cvars default values.

Five your using fun, whats up with that?

Heres mine:

Code:
#include <amxmodx> #include <fun> public plugin_init() {     register_plugin("God in Server", "0.1", "Mel")     register_cvar("amx_god","0")     register_cvar("mp_god","0")   }       public client_putinserver(id) {     if (get_cvar_num("amx_god") == 0) set_user_godmode(id, get_cvar_num("amx_god"))     else set_user_godmode(id, get_cvar_num("mp_god")) }

Or, my FM alternative:

Code:
#include <amxmodx> #include <fakemeta> #define set_user_godmode(%1,%2) set_pev(%1,pev_takedamage,%2*2) #define get_user_godmode(%1) (pev(%1,pev_takedamage) ) public plugin_init() {     register_plugin("God in Server", "0.1", "Mel")     register_cvar("amx_god","0")     register_cvar("mp_god","0")   }       public client_putinserver(id) {     if (get_cvar_num("amx_god") == 0) set_user_godmode(id, get_cvar_num("amx_god"))     else set_user_godmode(id, get_cvar_num("mp_god")) }

Try spelling the damn natives right next time, k?

NiGHTFiRE 03-17-2005 13:52

LoL, man thanks, I don't understand how stupid I can be some times :oops:
But one thing I don't understand is why did you add

register_cvar("mp_god", "0") and why did you add "0" after amx_god as well?
What does this do?
Code:
#define set_user_godmode(%1,%2) set_pev(%1,pev_takedamage,%2*2) #define get_user_godmode(%1) (pev(%1,pev_takedamage) )

I thought i would need to use fun bc set_user_godmode is ni the fun.inc
Sorry that I'm noob.

Twilight Suzuka 03-17-2005 15:48

Quote:

Originally Posted by NiGHTFiRE
LoL, man thanks, I don't understand how stupid I can be some times :oops:
But one thing I don't understand is why did you add

register_cvar("mp_god", "0") and why did you add "0" after amx_god as well?
What does this do?
Code:
#define set_user_godmode(%1,%2) set_pev(%1,pev_takedamage,%2*2) #define get_user_godmode(%1) (pev(%1,pev_takedamage) )

I thought i would need to use fun bc set_user_godmode is ni the fun.inc
Sorry that I'm noob.

You used mp_god, but did not register it. You registered amx_god.
You must give a cvar a default value, thus the 0.

those defines make FM defines of FUN stock, set_user_god and get_user_god. I hate FUN, so I made a list of stocks to replace its functions.

NiGHTFiRE 03-18-2005 09:51

ok thanx man, I have made a new plugin with almost the same code. Do you think I scripted this bad or good and if bad what should i do better?
Code:
#include <amxmodx> #include <fakemeta> #define set_user_health(%1,%2) set_pev(%1,pev_takedamage,%2*2) #define get_user_health(%1) (pev(%1,pev_takedamage) ) public plugin_init() {     register_plugin("Health in Server", "01", "NiGHTFiRE")     register_cvar("amx_health","0")     register_cvar("mp_health","0")   }       public client_putinserver(id) {     if (get_cvar_num("amx_health") == 0) set_user_health(id, get_cvar_num("amx_health"))     else set_user_health(id, get_cvar_num("mp_health")) }

The meaning of this code is to get the player when he joins to get tha mopunt of hp you have set with amx_health

Freecode 03-18-2005 12:09

Twilight u were really stupid for using FM. The kid is a newb and now u got him even more confused. Next time keep ur preferences and likes to yourself :wink:

Twilight Suzuka 03-18-2005 15:35

1 Attachment(s)
What, is it my fault for thinking fun module is a waste of perfectly good CPU and memory?

Look at the attached file. I converted every function from fun but give_item (which I can do, just lazy) and hitzones, to FM. I could do it to engine just as easily.

Why do we still have fun module then, when we could replace it with a stock file, and move the rest of its functions to core or to engine? Its archaic.

LynX 03-18-2005 17:43

Maybe your right - but FakeMeta isn't really a tool for newbies to play with.
I agree that its using CPU w/o any reason if theres only one set_user_godmode or set_user_health native - but its made as its made. I think it shouldn't be replaced so easily, and if some1 wants to save CPU time, go ahead.

P.S.

THNX for the stocks ! ;)

Freecode 03-18-2005 22:06

Quote:

Originally Posted by Twilight Suzuka
What, is it my fault for thinking fun module is a waste of perfectly good CPU and memory?

Look at the attached file. I converted every function from fun but give_item (which I can do, just lazy) and hitzones, to FM. I could do it to engine just as easily.

Why do we still have fun module then, when we could replace it with a stock file, and move the rest of its functions to core or to engine? Its archaic.

i understand that but thats not what the guy asked. u just made him so confused

Twilight Suzuka 03-18-2005 22:36

Yeah. Ok. But that's not really my fault.


All times are GMT -4. The time now is 14:12.

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