AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Amxx studio error! (https://forums.alliedmods.net/showthread.php?t=237490)

Hologram 03-25-2014 05:58

Amxx studio error!
 
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...

YamiKaitou 03-25-2014 06:20

Re: Amxx studio error!
 
Post the code and the error

Hologram 03-25-2014 13:10

Re: Amxx studio error!
 
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?

YamiKaitou 03-25-2014 13:19

Re: Amxx studio error!
 
No, if you want assistance on this Public forum, post all the needed details publicly

Black Rose 03-25-2014 13:21

Re: Amxx studio error!
 
Quote:

Originally Posted by Hologram (Post 2115794)
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.

Hologram 03-26-2014 03:28

Re: Amxx studio error!
 
/* 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).

extream87 03-26-2014 09:27

Re: Amxx studio error!
 
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; }

Black Rose 03-26-2014 16:22

Re: Amxx studio error!
 
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.

extream87 03-26-2014 17:32

Re: Amxx studio error!
 
Yes sound/ is not needed amxx assumes the sound is in sound folder.
My mistake :P

Hologram 03-27-2014 07:01

Re: Amxx studio error!
 
Hii ty guys I am a newbie to this and ty for correcting errors so I shall be posting the plugin asap :D


All times are GMT -4. The time now is 06:04.

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