Raised This Month: $ Target: $400
 0% 

No errors or warnings, yet it doesnt work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RogerGjyieah
Junior Member
Join Date: Jun 2010
Location: Denmark
Old 06-15-2010 , 10:11   No errors or warnings, yet it doesnt work
Reply With Quote #1

Hey!
I'm new to plugin-scripting, and this is my first 'real' plugin. There is no errors nor warnings with AMXMODX Studio, but it still doesn't work.

It is supposed to (in CS 1.6) spawn a grenade of the users choice after a predefined span of time. The sma-file is attached.

Any advice will be appriecieted.
Attached Files
File Type: sma Get Plugin or Get Source (TheNadeSpawn.sma - 658 views - 2.6 KB)
RogerGjyieah is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-15-2010 , 10:32   Re: No errors or warnings, yet it doesnt work
Reply With Quote #2

Is there anything in the Error Logs?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
RogerGjyieah
Junior Member
Join Date: Jun 2010
Location: Denmark
Old 06-15-2010 , 10:35   Re: No errors or warnings, yet it doesnt work
Reply With Quote #3

As said, AmxModX Studio did not repport any errors or warnings when i compiled it.. yet it says 'bad load' when i typen amx_plugins in cs console..
RogerGjyieah is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-15-2010 , 10:37   Re: No errors or warnings, yet it doesnt work
Reply With Quote #4

Then use "amxx plugins" and see why it is giving a bad load. Also, the Error Logs are the logs generated by AMXX when a plugin encounters a run-time error, not the compile errors
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 06-15-2010 , 10:43   Re: No errors or warnings, yet it doesnt work
Reply With Quote #5

PHP Code:
#include <amxconst> 
is not needed, it is automaticly included with <amxmodx>

PHP Code:
Params[0] = get_cvar_num("amx_NadeSpawn_Time")    //Param[0] = Spawn time for a nade
    
Params[1] = get_cvar_num("amx_NadeSpawn_Type")    //Param[1] = Type of nade (1 = He | 2 = Flash | 3 = Smoke) 
You should use pcvars, because they are faster. Like this:
PHP Code:
new cvar_typecvar_time

public plugin_init() {
    new 
NadeSpawnOn 1    //used by Toogle
    
register_plugin(PLUGINVERSIONAUTHOR)    
    
register_clcmd("amx_NadeSpawn_Toogle""Toogle"//Toogle's NadeSpawn on and off
    
cvar_type register_cvar("amx_NadeSpawn_Type""1")    //which type of grenade
    
cvar_time register_cvar("amx_NadeSpawn_Time""5")    //Time in sec before grenade spawns
    
register_clcmd("amx_NadeSpawn_Help""Help")    //Displays some help in the console
    
    //Define Parameters for SpawnNade loop:
    
new Params[2]
    
Params[0] = get_pcvar_num(cvar_time)    //Param[0] = Spawn time for a nade
    
Params[1] = get_pcvar_num(cvar_type)    //Param[1] = Type of nade (1 = He | 2 = Flash | 3 = Smoke) 
Use a switch here:
PHP Code:
public PreSpawnNade(SpawnTimenumNadeTypeid) {
    
//check what nade we are spawning..
    
if (numNadeType == 1) {
        
set_task(float(SpawnTime), "SpawnHE")
    }
    if (
numNadeType == 2) {
        
set_task(float(SpawnTime), "SpawnFlash")
    }
    if (
numNadeType == 3) {
        
set_task(float(SpawnTime), "SpawnSmoke")
    }


PHP Code:
public PreSpawnNade(SpawnTimenumNadeTypeid) {
    
//check what nade we are spawning..
    
switch(numNadeType)
    {
        case 
1:
            
set_task(float(SpawnTime), "SpawnHE")
        case 
2:
            
set_task(float(SpawnTime), "SpawnFlash")
        
        case 
3:
            
set_task(float(SpawnTime), "SpawnSmoke")
    }

instead of setting bpammo, use give_item from
PHP Code:
 #include <fun>

give_item(id"weapon_hegrenade"
and it doesn't work because you use id in preSpawnNade, but you don't got id there. I recommend using hamsandwich to detecht player spawn, and call that function there.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 06-15-2010 at 14:45.
drekes is offline
Send a message via MSN to drekes
RogerGjyieah
Junior Member
Join Date: Jun 2010
Location: Denmark
Old 06-15-2010 , 14:43   Re: No errors or warnings, yet it doesnt work
Reply With Quote #6

thanks
I'll try/do that..
RogerGjyieah is offline
RogerGjyieah
Junior Member
Join Date: Jun 2010
Location: Denmark
Old 06-16-2010 , 06:27   Re: No errors or warnings, yet it doesnt work
Reply With Quote #7

I've re-written it all, and now i get no errors from the compiler, nor amx-logs. But it still doesn't work!

I think the problem lies in this:
PHP Code:
public HE_was_thrown() {
    if (
NadeSpawnOn == 1) {
        if (
GetNadeType() == 1) {
            
set_task(get_pcvar_float(cvar_time), "SpawnHE")
        }
    }
    return 
PLUGIN_HANDLED

or perhaps in:

PHP Code:
public SpawnHE(id) {
    if (
is_user_alive(id)) {
        
give_item(id"weapon_hegrenade")
    }

cvar_time is set to be 3.0, so it should be a float..
Once again I have linked the entire plugin here..

Another thing wich annoys me is, that my plugin apearantly needs to be set in "debug mode", as I am using RegisterHam().. Is there no way to avoid that?
Attached Files
File Type: sma Get Plugin or Get Source (TheNadeSpawn.sma - 489 views - 3.0 KB)
RogerGjyieah is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 06-16-2010 , 07:00   Re: No errors or warnings, yet it doesnt work
Reply With Quote #8

PHP Code:
public HE_was_thrown() {
    if (
NadeSpawnOn == 1) {
        if (
GetNadeType() == 1) {
            
set_task(get_pcvar_float(cvar_time), "SpawnHE")
        }
    }
    else {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_HANDLED

You have to pass the id of the player in that function and the other 2 PrimaryAttack so you know who you should give the nade to.
PHP Code:
public HE_was_thrown(id) {
    if (
NadeSpawnOn == 1) {
        if (
GetNadeType() == 1) {
            
set_task(get_pcvar_float(cvar_time), "SpawnHE"id)
        }
    }
    else {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_HANDLED

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
RogerGjyieah
Junior Member
Join Date: Jun 2010
Location: Denmark
Old 06-16-2010 , 07:57   Re: No errors or warnings, yet it doesnt work
Reply With Quote #9

still doesn't work..

BTW, is the ID in set_task not an individual ID for the task (which is only used in case u wanna terminate the task)?
RogerGjyieah is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-16-2010 , 10:00   Re: No errors or warnings, yet it doesnt work
Reply With Quote #10

The task id passed to set task acts as the unique id for that task and can also be used to pass a player id (or any integer val) to the called function.

PHP Code:
set_task1.0 "function" id )

//both of the below will work
remove_taskid 

public function( 
id )
{
      
//code

__________________
Bugsy 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 14:47.


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