Raised This Month: $51 Target: $400
 12% 

Amxx studio error!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hologram
Junior Member
Join Date: Mar 2014
Old 03-25-2014 , 05:58   Amxx studio error!
Reply With Quote #1

Hii guys i am making a plugin.

I needed help.
I have scripted my plugin but theres an error while compiling...
It says smthing about line 36.
And guys i shall send the code only on request pls help me and tell me whats wrong...
Hologram is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-25-2014 , 06:20   Re: Amxx studio error!
Reply With Quote #2

Post the code and the error
__________________
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
Hologram
Junior Member
Join Date: Mar 2014
Old 03-25-2014 , 13:10   Re: Amxx studio error!
Reply With Quote #3

Sir yamikitou pls understand I am making a new plugin but if it leaks ill have nothing left so pls can I send u the code personally?
Hologram is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-25-2014 , 13:19   Re: Amxx studio error!
Reply With Quote #4

No, if you want assistance on this Public forum, post all the needed details publicly
__________________
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
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-25-2014 , 13:21   Re: Amxx studio error!
Reply With Quote #5

Quote:
Originally Posted by Hologram View Post
Sir yamikitou pls understand I am making a new plugin but if it leaks ill have nothing left so pls can I send u the code personally?
Read his signature.
Nobody wants to steal your code because someone already made it and/or someone can make it without even looking at your code.
At least copy the error produced so we can take guesses.
__________________
Black Rose is offline
Hologram
Junior Member
Join Date: Mar 2014
Old 03-26-2014 , 03:28   Re: Amxx studio error!
Reply With Quote #6

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define PLUGIN "Headshot Double Frag"
#define VERSION "1.0"
#define AUTHOR "Phantom~"

new toggle
new frags
new sound

new pun_list[][]
{
"%s has turned %s head into a red jello!!"
"%s gave %s a glimpse of his cold blooded murder !!!!"
};

new plugin_precache()
{
precache_sound("sound/headshot.wav")
}

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("deathmsg", "hook_death", "a");
toggle = register_pcvar("hsdf_enabled" "1");
sounds = register_cvar("kdf_sounds","1");
frags = register_pcvar("hsdf_frags" "1");

}
public hook_death()
{
if(get_pcvar_num(toggle) != 1)
return PLUGIN_HANDLED;
new amount = 0;
new killer = read_data(1);
new victim = read_data(2);
new kname[32]; get_user_name(killer,kname,31);
new vname[32]; get_user_name(victim,vname,31);
new weapon[24];
new namount[32];
read_data(4,weapon,23);

if(weapon[0] == 'k' && get_user_team(killer) != get_user_team(victim))
{
inc_frag(killer);
if(get_pcvar_num(getmoney) == 1)
{
amount = cs_get_user_frags(victim)*random(5)/4;
}
num_to_str(amount, namount, 32);
if(bsounds(sounds)) client_cmd(0,"spk misc/headshot");
}

return PLUGIN_HANDLED;
}

inc_frag(index)
{
if(!is_user_connected(index)) return;
set_user_frags(index,get_user_frags(index)+ge t_pcvar_num(frags));
}


bool: bsounds(pcvar)
{
if(get_pcvar_num(pcvar) == 1)
return true;
return false;
}




This is the code its not compiling.

The Errors:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team

Error: Start of function body without function header on line 17
Error: Invalid function or declaration on line 20
Error: Expected token: ";", but found "(" on line 22
Error: Undefined symbol "register_pcvar" on line 31
Warning: Expression has no effect on line 31
Error: Expected token: ";", but found ")" on line 31
Error: Invalid expression, assumed zero on line 31
Error: Too many error messages on one line on line 31

Compilation aborted.
7 Errors.
Could not locate output file (compile failed).

Last edited by Hologram; 03-26-2014 at 03:34.
Hologram is offline
extream87
Senior Member
Join Date: Aug 2011
Old 03-26-2014 , 09:27   Re: Amxx studio error!
Reply With Quote #7

Done.
Attention you are not using pun_list and you cant register pcvar you need to regist cvar and use get_pcvar_num or something.
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> #define PLUGIN "Headshot Double Frag" #define VERSION "1.0" #define AUTHOR "Phantom~" new toggle,getmoney,sounds,frags; new pun_list[][] = { "%s has turned %s head into a red jello!!", "%s gave %s a glimpse of his cold blooded murder !!!!" };//pun_list is never used public plugin_precache() { precache_sound("sound/headshot.wav"); } public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_event("deathmsg", "hook_death" ,"a"); toggle = register_cvar("hsdf_enabled" ,"1"); sounds = register_cvar("kdf_sounds","1"); //you need to use get_pcvar_num frags = register_cvar("hsdf_frags" ,"1"); //you need to use get_pcvar_num } public hook_death() { if(get_pcvar_num(toggle) != 1) return PLUGIN_HANDLED; new amount = 0; new killer = read_data(1); new victim = read_data(2); new kname[32]; get_user_name(killer,kname,31); new vname[32]; get_user_name(victim,vname,31); new weapon[24]; new namount[32]; read_data(4,weapon,23); if(weapon[0] == 'k' && get_user_team(killer) != get_user_team(victim)) { inc_frag(killer); if(get_pcvar_num(getmoney) == 1) { amount = get_user_frags(victim)*random(5)/4; } num_to_str(amount, namount, 32); if(bsounds(sounds)) client_cmd(0,"spk misc/headshot.wav"); } return PLUGIN_HANDLED; } inc_frag(index) { if(!is_user_connected(index)) return; set_user_frags(index,get_user_frags(index)+get_pcvar_num(frags)); } bool: bsounds(pcvar) { if(get_pcvar_num(pcvar) == 1) return true; return false; }

Last edited by extream87; 03-26-2014 at 09:43.
extream87 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-26-2014 , 16:22   Re: Amxx studio error!
Reply With Quote #8

I have a couple comments still.

Code:
    precache_sound("sound/headshot.wav");
I'm not sure here but I think sound/ is not required when precaching a sound file through precache_sound(). It will assume the sound folder, so this will print as "sound/sound/headshot.wav". At least I get this error: "Warning: Unable to open sound/sound/headshot.wav for transfer"

Code:
register_event("deathmsg", "hook_death" ,"a");
Events are case-sensitive. "DeathMsg" would be correct. You could also filter away killer being 0 and the wepon here. by adding this to the end of that function
Code:
"1!0", "4=knife"
This basically means "parameter 1 is not equal to 0" and "parameter 4 is equal to knife".
You could also add "3=1" to make it only for headshots.
Here's a full example that will only get called if the killer is not the server/map/worldspawn (suicide), it's a headshot and it's done with a knife:
Code:
register_event("DeathMsg", "hook_death" ,"a", "1!0", "3=1", "4=knife");

To make sure the killer is a player and not an entity you should check if the player is in the range of 1 and maxplayers. Create a global variable named g_maxplayers and retrieve get_maxplayers() on plugin_init(). Assign that value to the global variable. In the DeathMsg event you need to check if ( killer <= g_maxplayers ) before running any player based functions (like get_user_name(), get_user_team() or get_user_frags()) on that id.

I can see that it's not done so I will stop there for now and let you try for yourself a bit. Just come back if you have more problems. But at least register a cvar for the getmoney pointer because you will get runtime errors if trying to retrieve a value on a cvar pointer that doesn't exist.
__________________
Black Rose is offline
extream87
Senior Member
Join Date: Aug 2011
Old 03-26-2014 , 17:32   Re: Amxx studio error!
Reply With Quote #9

Yes sound/ is not needed amxx assumes the sound is in sound folder.
My mistake

Last edited by extream87; 03-26-2014 at 17:33.
extream87 is offline
Hologram
Junior Member
Join Date: Mar 2014
Old 03-27-2014 , 07:01   Re: Amxx studio error!
Reply With Quote #10

Hii ty guys I am a newbie to this and ty for correcting errors so I shall be posting the plugin asap
Hologram 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 05:34.


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