Raised This Month: $32 Target: $400
 8% 

Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
strangeguy
Senior Member
Join Date: Mar 2019
Old 06-26-2021 , 15:27   Help
Reply With Quote #1

Hi!
Someone can fix this plugin? I'm beginner in scripts and i don't know what's mistakes I was made because this plugin is not compiled for me.

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <nvault>

#define iKiller

new kill[32];
new g_save;

public plugin_init()
{
    register_plugin("Kill Count", "1.0", "Me");
    register_event("DeathMsg", "Event_DeathMsg", "a", "");
    g_save = nvault_open("kills");
    return 0;
}

public Event_DeathMsg()
{
    if (is_user_alive(iKiller) && cs_get_user_team(iVictim))
    {
        kill[iKiller]++;
    }
    return 0;
}

public plugin_natives()
{
    register_native("get_user_kills", "native_kills", 1);
    return 0;
}

public native_kills(id)
{
    return kill[id][0][0];
}

public client_disconnect(id)
{
    save(id);
    return 0;
}

public client_putinserver(id)
{
    set_task(2.00, "save_kills", id, "", 0, "", 0);
    return 0;
}

public save_kills(id)
{
    load(id);
    return 0;
}

public save(id)
{
    new vaultkey[64];
    new vaultdata[256];
    new name[33];
    get_user_name(id, name, 32);
    format(vaultkey, 63, "%s-/", name);
    format(vaultdata, 255, "%i#", kill[id]);
    nvault_set(g_save, vaultkey, vaultdata);
    return 0;
}

public load(id)
{
    new vaultkey[64];
    new vaultdata[256];
    new name[33];
    get_user_name(id, name, 32);
    format(vaultkey, 63, "%s-/", name);
    format(vaultdata, 255, "%i#", kill[id]);
    nvault_get(g_save, vaultkey, vaultdata, 255);
    replace_all(vaultdata, 255, "#", " ");
    new kill1[32];
    parse(vaultdata, kill1, 31);
    kill[id] = str_to_num(kill1);
    return 0;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1250\\ deff0\\ deflang1045{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/
strangeguy is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 06-26-2021 , 16:13   Re: Help
Reply With Quote #2

Found something i made for someone else in the past. Might be useful for you. Also, if you're trying to learn, don't just ask to "fix" a code. Ask for help and try to understand what's wrong.

PHP Code:
#include <amxmodx>
#include <nvault>

#pragma semicolon 1

#if !defined MAX_PLAYERS
    
const MAX_PLAYERS 32;
#endif

#if AMXX_VERSION_NUM < 190
    #define client_disconnected(%1) client_disconnect(%1)
#endif

new const szVersion[] = "1.0.0";

new 
iKnifeCount[MAX_PLAYERS 1];

new 
iVault;

public 
plugin_init() {
      
register_plugin("KnifeKillCount"szVersion"NapoleoN#");

      
register_clcmd("say /kc""KnifeCount");

      
register_event("DeathMsg""eDeath""a""1>0");

      
iVault nvault_open("KnifeKillCount");
}

public 
plugin_end() {
    
nvault_close(iVault);
}

public 
client_disconnected(id) {
    
SaveData(id);
}

public 
client_authorized(id) {
    
LoadData(id);
}

public 
eDeath() {
    new 
iAttacker read_data(1);
    new 
iClipiAmmoiWeapon;
    
iWeapon get_user_weapon(iAttackeriClipiAmmo);

    if(
iWeapon == CSW_KNIFE && is_user_connected(iAttacker)) {
        
iKnifeCount[iAttacker]++;
    }
}

public 
KnifeCount(id) {
    
client_print(idprint_chat"Knife KillCount: %i"iKnifeCount[id]);
}

SaveData(id) {
    new 
szAuth[35], szTemp[10];
    
get_user_authid(idszAuthcharsmax(szAuth));

    
formatex(szTempcharsmax(szTemp), "%i"iKnifeCount[id]);

    
nvault_set(iVaultszAuthszTemp);
}

LoadData(id) {
    new 
szAuth[35], szKillCount[10], szTemp[10];
    
get_user_authid(idszAuthcharsmax(szAuth));

    
nvault_get(iVaultszAuthszTempcharsmax(szTemp));

    
parse(szTempszKillCountcharsmax(szKillCount));

    
iKnifeCount[id] = str_to_num(szKillCount);

__________________

Last edited by Napoleon_be; 06-27-2021 at 09:06.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-26-2021 , 16:30   Re: Help
Reply With Quote #3

iKiller and iVictim are not variables and you haven't assigned them any values. You need to first create the variables (e.g. new iKiller, iVictim) and then you need to assign them the proper value. In the case of the DeathMsg event, the first and second parameters of the even are the entity indices for the killer and the victim, respectively. You get the event parameters with read_data(). Here is an example of this in only two lines:

Code:
	new iKiller = read_data(1)
	new iVictim = read_data(2)
Also, you'll need to remove #define iKiller because it does not declare a variable and will break your code.

Other issues include that you are using cstrike functions but you have not included the cstrike module. Then, you're trying to index an array using 3 indices which is not value because the variable is a single dimension.
__________________
fysiks is offline
strangeguy
Senior Member
Join Date: Mar 2019
Old 06-26-2021 , 16:55   Re: Help
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
iKiller and iVictim are not variables and you haven't assigned them any values. You need to first create the variables (e.g. new iKiller, iVictim) and then you need to assign them the proper value. In the case of the DeathMsg event, the first and second parameters of the even are the entity indices for the killer and the victim, respectively. You get the event parameters with read_data(). Here is an example of this in only two lines:

Code:
	new iKiller = read_data(1)
	new iVictim = read_data(2)
Also, you'll need to remove #define iKiller because it does not declare a variable and will break your code.

Other issues include that you are using cstrike functions but you have not included the cstrike module. Then, you're trying to index an array using 3 indices which is not value because the variable is a single dimension.
Thanks for help
strangeguy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-26-2021 , 17:57   Re: Help
Reply With Quote #5

Napoleon_be may i ask why did you add the condition "1!2" to the register_event ?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 06-27-2021 , 09:06   Re: Help
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
Napoleon_be may i ask why did you add the condition "1!2" to the register_event ?
That's my bad, it shouldn't be there, i removed it. I didn't take much time reading the code anyways. The first condition is enough. Yet, the code is incomplete. There should be a few more checks within the event function, such as iVictim != iAttacker, team attacker != team victim, ...
__________________

Last edited by Napoleon_be; 06-27-2021 at 09:11.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 06-27-2021 , 16:40   Re: Help
Reply With Quote #7

Quote:
Originally Posted by Napoleon_be View Post
Found something i made for someone else in the past. Might be useful for you. Also, if you're trying to learn, don't just ask to "fix" a code. Ask for help and try to understand what's wrong.

PHP Code:
#include <amxmodx>
#include <nvault>

#pragma semicolon 1

#if !defined MAX_PLAYERS
    
const MAX_PLAYERS 32;
#endif

#if AMXX_VERSION_NUM < 190
    #define client_disconnected(%1) client_disconnect(%1)
#endif

new const szVersion[] = "1.0.0";

new 
iKnifeCount[MAX_PLAYERS 1];

new 
iVault;

public 
plugin_init() {
      
register_plugin("KnifeKillCount"szVersion"NapoleoN#");

      
register_clcmd("say /kc""KnifeCount");

      
register_event("DeathMsg""eDeath""a""1>0");

      
iVault nvault_open("KnifeKillCount");
}

public 
plugin_end() {
    
nvault_close(iVault);
}

public 
client_disconnected(id) {
    
SaveData(id);
}

public 
client_authorized(id) {
    
LoadData(id);
}

public 
eDeath() {
    new 
iAttacker read_data(1);
    new 
iClipiAmmoiWeapon;
    
iWeapon get_user_weapon(iAttackeriClipiAmmo);

    if(
iWeapon == CSW_KNIFE && is_user_connected(iAttacker)) {
        
iKnifeCount[iAttacker]++;
    }
}

public 
KnifeCount(id) {
    
client_print(idprint_chat"Knife KillCount: %i"iKnifeCount[id]);
}

SaveData(id) {
    new 
szAuth[35], szTemp[10];
    
get_user_authid(idszAuthcharsmax(szAuth));

    
formatex(szTempcharsmax(szTemp), "%i"iKnifeCount[id]);

    
nvault_set(iVaultszAuthszTemp);
}

LoadData(id) {
    new 
szAuth[35], szKillCount[10], szTemp[10];
    
get_user_authid(idszAuthcharsmax(szAuth));

    
nvault_get(iVaultszAuthszTempcharsmax(szTemp));

    
parse(szTempszKillCountcharsmax(szKillCount));

    
iKnifeCount[id] = str_to_num(szKillCount);


Code:
register_event("DeathMsg", "eDeath", "a", "4=knife")
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 06-27-2021 , 17:04   Re: Help
Reply With Quote #8

Quote:
Originally Posted by iceeedr View Post
Code:
register_event("DeathMsg", "eDeath", "a", "4=knife")
I had no clue, thanks for this.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 23:36.


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