Problema salvare ammo packs

Tutoriale scripting, cod si portiuni de cod.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
JUSTINR
Membru, skill 0
Membru, skill 0
Posts: 38
Joined: 27 Nov 2020, 08:42
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 3 times

16 Jun 2022, 14:35

Buna ziua , am acest plugin de auto ammo save, dar la anumiti playeri li se reseteaza / nu se salveaza , ma puteti ajuta ?
| Afiseaza codul
#include <amxmodx>
#include <fakemeta>
#include <zombie_plague_advance>
#include <nvault>

#define PLUGIN	"[ZP] Can Auto Save Ammo"
#define VERSION	"0.1.0"
#define AUTHOR	"HsK"

new g_save, g_ammo[33], g_ammo_can_save[33]
new cvar_save_in

#define MAX_SAVE 9999999990	//can save....

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)

	register_event("DeathMsg","event_deathmsg","a")
	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")

	cvar_save_in = register_cvar("zp_ammo_save_in", "0")			// 0 = name / 1 = ip / 2 = steam id

	g_save = nvault_open("g_ammo_save1")
}

// Save Ammo
public zp_user_infected_post(id, infector)
{
	if (g_ammo_can_save[infector])
		Save_Ammo_date(infector)
	
	if (g_ammo_can_save[id])
		Save_Ammo_date(id)
}

public zp_extra_item_selected(id, itemid)
{
	if (g_ammo_can_save[id])
		Save_Ammo_date(id)
}

public event_deathmsg()
{
	new killer = read_data(1)
	new victim = read_data(2)

	if (!killer && !victim)
		return PLUGIN_CONTINUE;

	if (g_ammo_can_save[killer])
		Save_Ammo_date(killer)
			
	if (g_ammo_can_save[victim])
		Save_Ammo_date(victim)

	return PLUGIN_CONTINUE;
}

public fw_PlayerPreThink(id)
{
	if (g_ammo_can_save[id])
	{
		new ammo_packs = zp_get_user_ammo_packs(id)
		g_ammo[id] = ammo_packs
	}

	return FMRES_IGNORED;
}

public client_disconnected(id)
{
	if(g_ammo_can_save[id])
		Save_Ammo_date(id)
}

public client_putinserver(id)
	set_task(2.0, "now_can_save", id)

public now_can_save(id)
{
	Load_Ammo_date(id)
	set_task(0.5, "can_save_true", id)
}

public can_save_true(id)
	g_ammo_can_save[id] = true

public Save_Ammo_date(id)
{
	new vaultkey[64], vaultdata[256]

	switch (get_pcvar_num(cvar_save_in))
	{
		case 0:
		{
			new name[33];
			get_user_name(id,name,32)
			
			format(vaultkey, 63, "%s-/", name)
		}
		case 1:
		{
			new player_ip[33]
			get_user_ip(id, player_ip, 32);

			format(vaultkey, 63, "%s-/", player_ip)
		}
		case 2:
		{
			new AuthID[33];
			get_user_authid(id, AuthID, 32);
			
			formatex(vaultkey, 64, "%s-/", AuthID);
		}
	}

	format(vaultdata, 255, "%i#", g_ammo[id])
	
	nvault_set(g_save, vaultkey, vaultdata)
	return PLUGIN_CONTINUE;
}

public Load_Ammo_date(id)
{
	new vaultkey[64], vaultdata[256]

	switch (get_pcvar_num(cvar_save_in))
	{
		case 0:
		{
			new name[33];
			get_user_name(id,name,32)
			
			format(vaultkey, 63, "%s-/", name)
		}
		case 1:
		{
			new player_ip[33]
			get_user_ip(id, player_ip, 32);

			format(vaultkey, 63, "%s-/", player_ip)
		}
		case 2:
		{
			new AuthID[33];
			get_user_authid(id, AuthID, 32);
			
			formatex(vaultkey, 64, "%s-/", AuthID);
		}
	}

	format(vaultdata, 255, "%i#", g_ammo[id])
	
	nvault_get(g_save, vaultkey, vaultdata, 255)
	replace_all(vaultdata, 255, "#", " ")
	
	new playammo[32]
	parse(vaultdata, playammo, 31)
	g_ammo[id] = str_to_num(playammo)
	
	set_ammo(id)
	
	return PLUGIN_CONTINUE;
}

public set_ammo(id)
{
	if (g_ammo[id] > MAX_SAVE)
	{
		zp_set_user_ammo_packs(id, MAX_SAVE)
		g_ammo[id] = MAX_SAVE
	}
	else
		zp_set_user_ammo_packs(id, g_ammo[id])
	client_print(id, print_chat, "Your Ammo is  :  %d ", g_ammo[id])
}
lexz
Membru, skill +1
Membru, skill +1
Posts: 270
Joined: 02 Nov 2020, 01:57
Detinator Steam: Da
SteamID: profiles/76561198070
Fond eXtream: 0
Discord: lexzor#0630
Has thanked: 17 times
Been thanked: 32 times

17 Jun 2022, 15:33

incearca-l pe asta

Code: Select all

#include <amxmodx>
#include <fakemeta>
#include <zombie_plague_advance>
#include <nvault>

#define PLUGIN	"[ZP] Can Auto Save Ammo"
#define VERSION	"0.1.0"
#define AUTHOR	"HsK"

new g_save, g_ammo[33], g_ammo_can_save[33]
new cvar_save_in

#define MAX_SAVE 9999999990	//can save....

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)

	register_event("DeathMsg","event_deathmsg","a")
	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")

	cvar_save_in = register_cvar("zp_ammo_save_in", "0")			// 0 = name / 1 = ip / 2 = steam id

	g_save = nvault_open("g_ammo_save1")
}

// Save Ammo
public zp_user_infected_post(id, infector)
{
	if (g_ammo_can_save[infector])
		Save_Ammo_date(infector)
	
	if (g_ammo_can_save[id])
		Save_Ammo_date(id)
}

public zp_extra_item_selected(id, itemid)
{
	if (g_ammo_can_save[id])
		Save_Ammo_date(id)
}

public event_deathmsg()
{
	new killer = read_data(1)
	new victim = read_data(2)

	if (!killer && !victim)
		return PLUGIN_CONTINUE;

	if (g_ammo_can_save[killer])
		Save_Ammo_date(killer)
			
	if (g_ammo_can_save[victim])
		Save_Ammo_date(victim)

	return PLUGIN_CONTINUE;
}

public fw_PlayerPreThink(id)
{
	if (g_ammo_can_save[id])
	{
		new ammo_packs = zp_get_user_ammo_packs(id)
		g_ammo[id] = ammo_packs
	}

	return FMRES_IGNORED;
}

public client_disconnected(id)
{
	if(g_ammo_can_save[id])
		Save_Ammo_date(id)
}

public client_putinserver(id)
	set_task(2.0, "now_can_save", id)

public now_can_save(id)
{
	Load_Ammo_date(id)
	set_task(0.5, "can_save_true", id)
}

public can_save_true(id)
	g_ammo_can_save[id] = true;

public Save_Ammo_date(id)
{
	new vaultkey[64], vaultdata[10]

	switch (get_pcvar_num(cvar_save_in))
	{
		case 0:
		{
			new name[33];
			get_user_name(id,name,32)
			
			formatex(vaultkey, 63, "%s", name)
		}
		case 1:
		{
			new player_ip[33]
			get_user_ip(id, player_ip, 32);

			formatex(vaultkey, 63, "%s", player_ip)
		}
		case 2:
		{
			new AuthID[33];
			get_user_authid(id, AuthID, 32);
			
			formatex(vaultkey, 63, "%s", AuthID);
		}

		default: log_amx("Invalid save type");
	}

	format(vaultdata, charsmax(vaultdata), "%i", g_ammo[id])
	
	nvault_set(g_save, vaultkey, vaultdata)
	return PLUGIN_CONTINUE;
}

public Load_Ammo_date(id)
{
	new vaultkey[64], vaultdata[10]

	switch (get_pcvar_num(cvar_save_in))
	{
		case 0:
		{
			new name[33];
			get_user_name(id,name,32)
			
			formatex(vaultkey, 63, "%s", name)
		}
		case 1:
		{
			new player_ip[33]
			get_user_ip(id, player_ip, 32);

			formatex(vaultkey, 63, "%s", player_ip)
		}
		case 2:
		{
			new AuthID[33];
			get_user_authid(id, AuthID, 32);
			
			formatex(vaultkey, 63, "%s", AuthID);
		}

		default: log_amx("Invalid save type");
	}
	
	new iTs;
	if(nvault_lookup(g_save, vaultkey, vaultdata, charsmax(vaultdata), iTs))
	{
		g_ammo[id] = str_to_num(vaultdata);
	}
	
	set_ammo(id)
	
	return PLUGIN_CONTINUE;
}

public set_ammo(id)
{
	if (g_ammo[id] > MAX_SAVE)
	{
		zp_set_user_ammo_packs(id, MAX_SAVE)
		g_ammo[id] = MAX_SAVE
	}
	else
		zp_set_user_ammo_packs(id, g_ammo[id])
	client_print(id, print_chat, "Your Ammo is  :  %d ", g_ammo[id])
}
JUSTINR
Membru, skill 0
Membru, skill 0
Posts: 38
Joined: 27 Nov 2020, 08:42
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 3 times

18 Jun 2022, 12:07

O sa-l pun pe server și o sa revin cu EDIT. Are vreo treaba dacă e amxmodx 1.8.3 ? Adică influențează cu ceva salvarea pe nvault?
lexz
Membru, skill +1
Membru, skill +1
Posts: 270
Joined: 02 Nov 2020, 01:57
Detinator Steam: Da
SteamID: profiles/76561198070
Fond eXtream: 0
Discord: lexzor#0630
Has thanked: 17 times
Been thanked: 32 times

18 Jun 2022, 17:44

n-ar trebui, baga-l si vezi
JUSTINR
Membru, skill 0
Membru, skill 0
Posts: 38
Joined: 27 Nov 2020, 08:42
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 3 times

19 Jun 2022, 20:33

Iar li se resetează la unii...chiar nu înțeleg
User avatar
N3v3rM1nd
Membru, skill +2
Membru, skill +2
Posts: 709
Joined: 06 Oct 2018, 13:41
Detinator Steam: Da
SteamID: /id/kidd0x/
Fond eXtream: 0
Location: Constangeles
Discord: kidd0x#1886
Has thanked: 112 times
Been thanked: 54 times

20 Jun 2022, 11:21

Daca e pus sa salveze pe steamid o sa salveze doar la cei cu steamon sau care au versiuni curate de cs
MIX-CORE Apasa aici
JUSTINR
Membru, skill 0
Membru, skill 0
Posts: 38
Joined: 27 Nov 2020, 08:42
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 3 times

20 Jun 2022, 11:24

E pe nickname ,e pus zp_ammo_save_in "0"
User avatar
N3v3rM1nd
Membru, skill +2
Membru, skill +2
Posts: 709
Joined: 06 Oct 2018, 13:41
Detinator Steam: Da
SteamID: /id/kidd0x/
Fond eXtream: 0
Location: Constangeles
Discord: kidd0x#1886
Has thanked: 112 times
Been thanked: 54 times

20 Jun 2022, 11:36

Numele se salveaza intr-un key, daca schimbi numele key-ul se schimba si el, si automat se reseteaza
MIX-CORE Apasa aici
lexz
Membru, skill +1
Membru, skill +1
Posts: 270
Joined: 02 Nov 2020, 01:57
Detinator Steam: Da
SteamID: profiles/76561198070
Fond eXtream: 0
Discord: lexzor#0630
Has thanked: 17 times
Been thanked: 32 times

20 Jun 2022, 14:39

N3v3rM1nd wrote:
20 Jun 2022, 11:21
Daca e pus sa salveze pe steamid o sa salveze doar la cei cu steamon sau care au versiuni curate de cs
n-are legatura
JUSTINR
Membru, skill 0
Membru, skill 0
Posts: 38
Joined: 27 Nov 2020, 08:42
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 3 times

20 Jun 2022, 16:52

Se poate face un plugin gen cum e salvarea la rank la ocixcrom ca știu ca salvează ok ala?
User avatar
Rainq
Fost moderator
Fost moderator
Posts: 2818
Joined: 21 Jul 2015, 18:50
Detinator Steam: Da
CS Status: Busy
Detinator server CS: zm.thexforce.ro
SteamID: mrainq
Reputatie: Fost super moderator
Fost detinator ZM.eXtreamCS.COM
Fost Membru Club eXtreamCS (trei luni)
Fond eXtream: 0
Location: Bucuresti
Has thanked: 31 times
Been thanked: 58 times
Contact:

21 Jun 2022, 17:49

Code: Select all

#include <amxmodx>
#include <cstrike>
#include <fvault>
#include <hamsandwich>

#define TASK_MINUTES 39292
#define ID_MINUTES (taskid - TASK_MINUTES)

native zp_get_user_ammo_packs(id);
native zp_set_user_ammo_packs(id, amount);

new const fvault_packs[] = "FvaultZombie_Packs";
new const fvault_minutes[] = "player_minutes";

new bool:g_isloaded[33], g_minutes[33], g_awardedbonus[33], g_msg_saytext;

public plugin_init()
{
	register_plugin("Auto Saver & Rewards", "1.0", "cyby");
	
	RegisterHam(Ham_Spawn, "player", "player_spawn_post", 1);
	
	register_clcmd("say /get", "get_rewards");
	g_msg_saytext = get_user_msgid("SayText");
}

public client_putinserver(id)
{
	if(!is_user_bot(id))
	{
		g_isloaded[id] = false;
		zp_set_user_ammo_packs(id, 0);
		g_minutes[id] = 0;
		g_awardedbonus[id] = 0;
	}
}

public client_authorized(id)
{
	if(!is_user_bot(id))
	{
		g_isloaded[id] = false;
		zp_set_user_ammo_packs(id, 0);
		g_minutes[id] = 0;
		g_awardedbonus[id] = 0;
	}
}

public client_disconnect(id)
{
	if(g_isloaded[id])
	{
		new stupidstats[22], name[32];
		get_user_name(id, name, charsmax(name));
		num_to_str(zp_get_user_ammo_packs(id), stupidstats, charsmax(stupidstats));
		fvault_set_data(fvault_packs, name, stupidstats);
		formatex(stupidstats, charsmax(stupidstats), "^"%d^" ^"%d^"", g_minutes[id], g_awardedbonus[id]);
		fvault_set_data(fvault_minutes, name, stupidstats);
	}
	remove_task(id+TASK_MINUTES);
}

public player_spawn_post(id)
{
	if(!is_user_alive(id) || is_user_bot(id))
		return;
		
	if(g_isloaded[id])
		return;
		
	new data_taked[22], playername[32], bool:newplayer = false;
	get_user_name(id, playername, charsmax(playername));

	if(fvault_get_data(fvault_packs, playername, data_taked, charsmax(data_taked)))
		zp_set_user_ammo_packs(id, str_to_num(data_taked)), color(id, "^4[ZP]^1 and ^3 %s^1 packs in your bank!", data_taked);
	else
		zp_set_user_ammo_packs(id, 253);
		
	if(fvault_get_data(fvault_minutes, playername, data_taked, charsmax(data_taked)))
	{
		new strmin[11], strawarded[11];
		parse(data_taked, strmin, charsmax(strmin), strawarded, charsmax(strawarded));
		g_minutes[id] = str_to_num(strmin);
		g_awardedbonus[id] = str_to_num(strawarded);
	}
	else
		newplayer = true;

	if(newplayer)
	{
		color(id, "^4[ZP]^1 Seems like you are new on this server!");
		color(id, "^4[ZP]^1 Your bonus is ready now, use the command^3 /get^1 in the chat to get^3 200^1 packs!");
	}
	g_isloaded[id] = true;
	set_task(60.0, "give_minutes", id+TASK_MINUTES, _, _, "b");
}

public get_rewards(id)
{
	if(!g_isloaded[id] || !is_user_connected(id))
		return PLUGIN_CONTINUE;
	
	new Float:isvalid = 0.0;
	isvalid = g_minutes[id] / 60.0;
	if(floatround(isvalid, floatround_tozero) > g_awardedbonus[id])
	{
		color(id, "^4[ZP]^1 You got^3 5 Packs^1 for playing on this server!");
		color(id, "^4[ZP]^1 Continue to play and you will get every hour^3 5 Packs^1!");
		zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + 5);
		g_awardedbonus[id]++;
		return PLUGIN_HANDLED;
	}
	
	//color(id, "^4[ZP]^1 Sorry, you need to wait a little bit more until you will get your next bonus!");
	return PLUGIN_HANDLED;
}

public give_minutes(taskid)
{
	if(!is_user_connected(ID_MINUTES) || cs_get_user_team(ID_MINUTES) == CS_TEAM_SPECTATOR || !cs_get_user_team(ID_MINUTES) || !g_isloaded[ID_MINUTES])
		return;
		
	g_minutes[ID_MINUTES]++;
	new Float:isvalid = 0.0;
	isvalid = g_minutes[ID_MINUTES] / 460.0;
	if(floatround(isvalid, floatround_tozero) > g_awardedbonus[ID_MINUTES])
		color(ID_MINUTES, "^4[ZP]^1 Take your^3 5 Packs^1 bonus now typing^3 /get^1 in chat.");
}
	
stock color(const id, const input[], any:...)
{
	new count = 1, players[32], msg[191];
	vformat(msg, charsmax(msg), input, 3);
	
	if(id) players[0] = id;
	else get_players(players, count, "ch")
	{
		for(new i = 0; i < count; i++)
		{
			if(is_user_connected(players[i]))
			{
				message_begin(MSG_ONE_UNRELIABLE, g_msg_saytext, _, players[i]);
				write_byte(players[i]);
				write_string(msg);
				message_end();
			}
		}
	}
}
Image
Post Reply

Return to “Scripting”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests