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

Help / Support help with /get ammo command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Riki1999
BANNED
Join Date: Aug 2023
Location: GB
Old 08-22-2023 , 20:58   help with /get ammo command
Reply With Quote #1

#include <amxmodx>
#include <zombieplague>
#include <nvault>

#define NV_NAME "GET_AMMO"
#define TAG "[ZP]"

enum player_struct {
mtime,bool:ftime,key[64]
}
new g_player[33][player_struct];

new cvar_save_type,cvar_time,cvar_ap;

public plugin_init() {

register_plugin("Get Ammo Packs", "1.0", "Clauu");

cvar_save_type = register_cvar("get_ammo_save_type","1"); // how to save data 1 by authid, 2 by ip or 3 by name
cvar_time = register_cvar("get_ammo_minutes","720"); // time in minutes, 720minutes=12hours it will be auto calculated
cvar_ap = register_cvar("get_ammo_packs","500"); // how many ammo packs to give

register_clcmd("say /get", "cmd_ap");
register_clcmd("say_team /get", "cmd_ap");
}

public cmd_ap(id) {

new nv = nvault_open(NV_NAME);

if(nv == INVALID_HANDLE) {
client_print(id,print_chat,"%s For the moment getting ammo packs system is inactive..",TAG);
return;
}

new txt_min[32],txt_ap[10];
new ap = get_pcvar_num(cvar_ap),pminutes = get_pcvar_num(cvar_time);
copy(txt_ap,charsmax(txt_ap),(ap==1)?"pack":" packs");
build_time(pminutes,txt_min,charsmax(txt_min) );

if(g_player[id][ftime]) {
client_print(id,print_chat,"%s You have just received %d ammo %s, get another in %s !",TAG,ap,txt_ap,txt_min);
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + ap);
g_player[id][ftime]=false;
nvault_touch(nv,g_player[id][key],g_player[id][mtime]=get_systime());
return;
}

new user_time=get_systime()-g_player[id][mtime];
new diff_min=(user_time<(pminutes*60))?pminutes-(user_time/60):pminutes;
build_time(diff_min,txt_min,charsmax(txt_min) );

if(user_time>=(pminutes*60)) {
client_print(id,print_chat,"%s You have just received %d ammo %s since %s passed !",TAG,ap,txt_ap,txt_min);
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + ap);
nvault_touch(nv,g_player[id][key],g_player[id][mtime]=get_systime());
}
else
client_print(id,print_chat,"%s Retry again in %s for getting %d more ammo %s !",TAG,txt_min,ap,txt_ap);

nvault_close(nv);
}

public client_putinserver(id) {

new nv,data[32];
get_auth(id,g_player[id][key],charsmax(g_player[][key]));
g_player[id][mtime]=get_systime();
g_player[id][ftime]=false;
formatex(data,charsmax(data),"%d",g_player[id][mtime]);

if((nv=nvault_open(NV_NAME))==INVALID_HANDLE)
return;

if(!nvault_lookup(nv,g_player[id][key],data,charsmax(data),g_player[id][mtime])) {
nvault_set(nv,g_player[id][key],data);
g_player[id][ftime]=true;
}

nvault_close(nv);
}

public client_disconnect(id) {

g_player[id][mtime]=0;
g_player[id][ftime]=false;
}

stock get_auth(id,data[],len)
switch(get_pcvar_num(cvar_save_type)) {
case 1: get_user_authid(id,data,len);
case 2: get_user_ip(id,data,len,1);
case 3: get_user_name(id,data,len);
}

stock build_time(pminutes,data[],len)
if(pminutes==1)
copy(data,len,"1 minute");
else if(pminutes!=1&&pminutes<60)
formatex(data,len,"%d minutes",pminutes);
else if(pminutes==60)
copy(data,len,"1 hour");
else {
new ptime=pminutes/60;
if(ptime*60==pminutes)
formatex(data,len,"%d %s",ptime,(ptime==1)?"hour":"hours");
else {
new diff=pminutes-ptime*60;
formatex(data,len,"%d %s and %d %s",ptime,(ptime==1)?"hour":"hours",diff,(dif f==1)?"minute":"minutes");
}
}
Riki1999 is offline
Send a message via ICQ to Riki1999 Send a message via AIM to Riki1999 Send a message via Yahoo to Riki1999 Send a message via Skype™ to Riki1999
Riki1999
BANNED
Join Date: Aug 2023
Location: GB
Old 08-22-2023 , 21:02   Re: help with /get ammo command
Reply With Quote #2

i dose not work and

do i need a - sma file for this
Attached Files
File Type: sma Get Plugin or Get Source (zp_get_ammo.sma - 79 views - 3.8 KB)
Riki1999 is offline
Send a message via ICQ to Riki1999 Send a message via AIM to Riki1999 Send a message via Yahoo to Riki1999 Send a message via Skype™ to Riki1999
franco sosa
Junior Member
Join Date: Jul 2023
Old 08-27-2023 , 18:32   Re: help with /get ammo command
Reply With Quote #3

Hello, will this code serve to save the ammo packs of each player?
franco sosa 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 15:25.


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