AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bad Load - I can't see the reason (https://forums.alliedmods.net/showthread.php?t=12861)

smdobay 04-27-2005 01:08

Bad Load - I can't see the reason
 
I can't figure out why I'm getting a bad load. It's probably a small trivial mistake I overlooked but I've gone over everything many times.

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <engine> public plugin_init(){     register_plugin("SpawnMoney","1.0","smdobay")     register_cvar("sv_spawnmoney","10",FCVAR_SPONLY)         set_task(0.5,"givemoney")         return PLUGIN_HANDLED } public givemoney(){     for (new i=0;i<=32;i++) {         cs_set_user_money(i,cs_get_user_money(i) + get_cvar_num("sv_spawnmoney"))     }         set_task(0.5,"givemoney")         return PLUGIN_HANDLED }

teame06 04-27-2005 01:14

Quote:

set_task(0.5,"givemoney")
i'm not sure but i don't think you want to do that in init. So are you trying to give money when the round starts?

xeroblood 04-27-2005 11:32

Re: Bad Load - I can't see the reason
 
The main reason I think it fails to load is because you are trying to assign money to players that don't exist, and most importantly, you are doing it as soon as the plugin is initialized, and there will be 0 players in the server at that point..

You see, you are trying to give money to every player every 1/2 second, but you aren't checking if the player even exists!! I hope you understand what I mean..

Now, I am guessing that you want to give players money every time they spawn, is this correct?? You could just hook the ReseyHUD event, and then give players money there.. like:

Code:
#include <amxmodx> #include <cstrike> // Return values are ignored by this forward-function.. public plugin_init(){     register_plugin("SpawnMoney","1.0","smdobay")         // The "b" flag means that this event will be called for each player         register_event( "ResetHUD",  "Event_ResetHUD",  "b" )         //  Only 10 dollars??     register_cvar("sv_spawnmoney","10",FCVAR_SPONLY) } public Event_ResetHUD( id ) {         if( !is_user_alive( id ) )             return PLUGIN_CONTINUE         cs_set_user_money( id, cs_get_user_money(id) + get_cvar_num("sv_spawnmoney") )         return PLUGIN_CONTINUE }

Maybe something like that??

XxAvalanchexX 04-27-2005 13:18

Would it really cause a bad load by trying to give money to players that don't exist, or simply runtime errors? Make sure that the cstrike module is enabled as well.

xeroblood 04-27-2005 18:05

Actually, I think you're right Avalanche, that possibility slipped my mind..
But either way, his method was a bad idea, I just assume (:() people have the modules working before trying to code with them..

So when ya gonna move outta your cardboard box? :P :D

smdobay 04-28-2005 13:49

Actually, the idea here is to give a player just a few $ every half second, not on respawn. I already wrote a plugin for that.
Thanks for reminding me to check if they're alive :oops:
Still, I wouldn't think that would cause a bad load.

[Edit]I figured it out. There was a small typo in the cs module in modules.ini. Thanks av.[/Edit]


All times are GMT -4. The time now is 16:44.

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