AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plugin Fix (https://forums.alliedmods.net/showthread.php?t=51007)

kmal2t 02-09-2007 00:00

Plugin Fix
 
See last post

Phantom Warrior 02-11-2007 00:47

Re: Plugin Fix
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <fakemeta>
 
#define AUTHOR "Chris"
#define VERSION "1.0"
#define PLUGIN "Permanent Kills/Deaths"

 
new const SAVE_FILE[] = "KillsDeaths";
new 
Vault;
 
public 
plugin_init()
{
    
register_plugin("Permanent Kills/Deaths"VERSION"Chris");
}
 
public 
client_putinserver(id)
{
    
LoadData(id);
    return 
PLUGIN_HANDLED;    
}
 
public 
client_disconnect(id)
{
    
SaveData(id);
    return 
PLUGIN_HANDLED;
}
 
GetSaveKey(idKey[])
{
static 
AuthId[32];
get_user_authid(id,AuthId,32);
format(Key63,"%s",AuthId);
}
 
public 
plugin_end()
{
new 
iPlayers[32],iNum;
for(new 
i=0;i<iNum;i++)
{
    
SaveData(iPlayers[i]);

 
return 
PLUGIN_HANDLED;
}
 
SaveData(id)
{
Vault nvault_open(SAVE_FILE);
 
if(
Vault == INVALID_HANDLE)
{
log_amx("Error opening nVault file: %s"SAVE_FILE);
return 
PLUGIN_HANDLED;
}
 
static 
Key[64], Data[30];
new 
sKills[15],sDeaths[15];
new 
TimeStamp;
 
if(
nvault_lookup(VaultKeyData29TimeStamp))
{
parse(Data,sKills,14,sDeaths,14);
}
 
new 
Kills str_to_num(sKills)
new 
Deaths str_to_num(sDeaths)
 
Kills += pev(idpev_frags); //problem
Deaths += get_user_deaths(id); //problem
 
GetSaveKey(id,Key);
 
format(Data29,"%i %i"KillsDeaths);
 
nvault_set(VaultKeyData);        
 
nvault_close(Vault);
 
return 
PLUGIN_HANDLED;
}
 
LoadData(id)
{
Vault nvault_open(SAVE_FILE);
 
if(
Vault == INVALID_HANDLE)
{
log_amx("Error opening nVault file: %s"SAVE_FILE);
return 
PLUGIN_HANDLED;
}
 
static 
Key[64], Data[30];
new 
TimeStamp;
 
GetSaveKey(id,Key);
 
if(
nvault_lookup(VaultKeyData29TimeStamp))
{
new 
sKills[15],sDeaths[15];
parse(Data,sKills,14,sDeaths,14);
 
set_pev(idpev_fragsstr_to_float(sKills));
set_pdata_int(id290str_to_num(sDeaths));
}
nvault_close(Vault);
 
return 
PLUGIN_HANDLED;



Phantom Warrior 02-11-2007 09:49

Re: Plugin Fix
 
Pffh, learn to read? And yeah thanks for -Karma.

I did change stuff.
You needed amxmisc.
You needed [32] not [31]
You needed a } not a {
You needed space not a ).
Thank you.

kmal2t 02-11-2007 23:31

Re: Plugin Fix
 
I didn't give you -karma.

stupok 02-12-2007 00:01

Re: Plugin Fix
 
The code below will save every time a client kills another client. That should simplify things for you.

Code:
/* Permanent Kills/Deaths v.1.0 by Chris/Unbonami <[email protected]> 17 Jan. 2007 This plugin saves the Kills and Deaths for each user(by steamid and mapname) When he gets on the same map again his Kills and Deaths are loaded. Possibles bugs: Kills or Deaths larger than an integer/float ? */ #include <amxmodx> #include <nvault> #include <fakemeta> #define VERSION "1.0" new const SAVE_FILE[] = "KillsDeaths"; new Vault; public plugin_init() {     register_plugin("Permanent Kills/Deaths", VERSION, "Chris");     register_event("DeathMsg", "Event_DeathMsg", "a", "1>0") } public Event_DeathMsg() {     new Killer = read_data(1)     new Victim = read_data(2)         SaveData(Killer)         if(Killer != Victim)     {         SaveData(Victim)     } } public client_putinserver(id) {     LoadData(id);     return PLUGIN_HANDLED;     } public client_disconnect(id) {     SaveData(id);     return PLUGIN_HANDLED; } stock GetSaveKey(id, Key[64]) {     static AuthId[33];     get_user_authid(id,AuthId,32);     format(Key, 63,"%s",AuthId); } public plugin_end() {     new iPlayers[32],iNum;     for(new i=0;i<iNum;i++)     {         SaveData(iPlayers[i]);     }         return PLUGIN_HANDLED; } public SaveData(id) {     Vault = nvault_open(SAVE_FILE);         if(Vault == INVALID_HANDLE)     {         log_amx("Error opening nVault file: %s", SAVE_FILE);         return PLUGIN_HANDLED;     }         static Key[64], Data[30];         new Kills = pev(id, pev_frags)     new Deaths = get_user_deaths(id)         GetSaveKey(id,Key);         format(Data, 29,"%i %i", Kills, Deaths);         nvault_set(Vault, Key, Data);                 nvault_close(Vault);         return PLUGIN_HANDLED; } public LoadData(id) {     Vault = nvault_open(SAVE_FILE);         if(Vault == INVALID_HANDLE)     {         log_amx("Error opening nVault file: %s", SAVE_FILE);         return PLUGIN_HANDLED;     }         static Key[64], Data[30];     new TimeStamp;         GetSaveKey(id,Key);         if(nvault_lookup(Vault, Key, Data, 29, TimeStamp))     {         new sKills[15],sDeaths[15];         parse(Data,sKills,14,sDeaths,14);                 set_pev(id, pev_frags, str_to_float(sKills));         set_pdata_int(id, 290, str_to_num(sDeaths));     }     nvault_close(Vault);         return PLUGIN_HANDLED; }

kmal2t 02-12-2007 00:50

Re: Plugin Fix
 
That unfortuantely doens't solve the problem of an sv_restart or the like being used and overwriting people's score.

Could you maybe write in a thing that if the commands sv_restart, sv_restartround, quit, restart, or kill etc are used it backs up the scores and sets everyone's again so they don't lose theirs?

Unfortunately a server shutdown or restart doesn't use any HL command so I have no idea if that would fuck up scores too :\ I'd just have to be careful to do it when no one is in the server.

stupok 02-12-2007 01:13

Re: Plugin Fix
 
Doh! The code I posted will not solve your problem. However, I will post tomorrow with a solution.

kmal2t 02-14-2007 22:15

Re: Plugin Fix
 
Forget it.

[ --<-@ ] Black Rose 02-15-2007 12:12

Re: Plugin Fix
 
Code:
public plugin_end() {     new iPlayers[32],iNum;     for(new i=0;i<iNum;i++)     {         SaveData(iPlayers[i]);     }             return PLUGIN_HANDLED; }
Why don't you try adding get_players()?

Code:
stock GetSaveKey(id, Key[64]) {     static AuthId[33];     get_user_authid(id,AuthId,32);     format(Key, 63,"%s",AuthId); }
Are you kiddin me?
Code:
stock GetSaveKey(id, Key[32])     get_user_authid(id, Key, 31);


All times are GMT -4. The time now is 00:37.

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