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

hello, this hat system gives coins at a certain time, but when the map changes, the c


Post New Thread Reply   
 
Thread Tools Display Modes
Erra
Member
Join Date: Jun 2021
Old 10-16-2021 , 21:38   Re: hello, this hat system gives coins at a certain time, but when the map changes, t
Reply With Quote #11

Quote:
Originally Posted by CrazY. View Post
Do you want it to still unlock hats depending on how much money you have or all hats should have no cost at all?
yes locks should be opened by quantity
and no tokens should be spent after the purchase regardless.
In my last request, could you please make a cvar code to give the token to someone?
and players can't enter the menu when they die please
Erra is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-17-2021 , 02:16   Re: hello, this hat system gives coins at a certain time, but when the map changes, t
Reply With Quote #12

Quote:
for(new i=1; i < sizeof(sHats);i++)
First hat is being ignored because you're starting the loop from the index 1 instead of 0.

Not sure why you've the first slot in the array empty.
But you can simply remove it and alter another method inorder to not to show the hats.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-17-2021 at 02:21.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Erra
Member
Join Date: Jun 2021
Old 10-17-2021 , 03:12   Re: hello, this hat system gives coins at a certain time, but when the map changes, t
Reply With Quote #13

Quote:
Originally Posted by Natsheh View Post
First hat is being ignored because you're starting the loop from the index 1 instead of 0.

Not sure why you've the first slot in the array empty.
But you can simply remove it and alter another method inorder to not to show the hats.
Unfortunately, I don't have enough coding knowledge, otherwise I would love to do it, sir.

Last edited by Erra; 10-17-2021 at 03:15.
Erra is offline
Erra
Member
Join Date: Jun 2021
Old 10-17-2021 , 03:13   Re: hello, this hat system gives coins at a certain time, but when the map changes, t
Reply With Quote #14

Quote:
Originally Posted by Erra View Post
yes locks should be opened by quantity
and no tokens should be spent after the purchase regardless.
In my last request, could you please make a cvar code to give the token to someone?
and players can't enter the menu when they die please
That's what I want, I'd be very grateful to you, sir.
Erra is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-17-2021 , 06:09   Re: hello, this hat system gives coins at a certain time, but when the map changes, t
Reply With Quote #15

I'll try to fix you the code when i am available on pc.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-17-2021 at 06:10.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Erra
Member
Join Date: Jun 2021
Old 10-17-2021 , 06:12   Re: hello, this hat system gives coins at a certain time, but when the map changes, t
Reply With Quote #16

Quote:
Originally Posted by Natsheh View Post
I'll try to fix you the code when i am available on pc.
I'm looking forward to it sir
Erra is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-18-2021 , 08:40   Re: hello, this hat system gives coins at a certain time, but when the map changes, t
Reply With Quote #17

There you go.

Commands:
amx_coin "player name or #userid" amount - give coin to a player
amx_takecoin "player name or #userid" amount - take coin from a player

Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <reapi>
#define Kac_Dakikada_Bir 5

new const sTag[] = "GitHub";

new g_vault

new const sHats[][][] = { {"","",0},
		{"Dede Sapkasi","models/hat/dede.mdl",100},
		{"Suratsiz Sapkasi","models/hat/suratsiz.mdl",100},
		{"Inek Sapkasi","models/hat/inek.mdl",200},
		{"Palyaco Sapkasi","models/hat/palyaco.mdl",300},
		{"Kedi Sapkasi","models/hat/kedi.mdl",400},
		{"Korku Sapkasi","models/hat/korku.mdl",700}
};
new iHatModels[sizeof(sHats)+1],iHatEnt[MAX_PLAYERS+1],iCoin[MAX_PLAYERS+1];
new g_authid[MAX_PLAYERS+1][MAX_AUTHID_LENGTH]
public plugin_precache() {
		for(new i=1; i < sizeof(sHats);i++)
				iHatModels[i] = precache_model(sHats[i][1][0]);
}
public plugin_natives() {
		register_native("nGetUserCoin","@NTV_CN");
}
@NTV_CN() {
		new iJlayer = get_param(1);
		return iCoin[iJlayer];
}
public plugin_init() {
		register_plugin("Sapka Menü", "1.0", "PawNod'");
 
		register_clcmd("say /sapka","@OpenHatMenu");
		register_clcmd("say /hat","@OpenHatMenu");

		register_concmd("amx_coin", "CmdGiveCoin")
		register_concmd("amx_takecoin", "CmdTakeCoin")

		g_vault = nvault_open("coins")
}

public plugin_end()
{
		if (g_vault != INVALID_HANDLE)
				nvault_close(g_vault)
}
public client_authorized(id, const authid[])
{
		if (!is_user_bot(id) && !is_user_hltv(id) && g_vault != INVALID_HANDLE)
		{
				copy(g_authid[id], charsmax(g_authid[]), authid)
				iCoin[id] = nvault_get(g_vault, authid)
		}
}
public client_disconnected(id)
{

		if (!is_user_bot(id) && !is_user_hltv(id) && g_vault != INVALID_HANDLE)
		{
				new value[32]
				formatex(value, charsmax(value), "%d", iCoin[id])
				nvault_set(g_vault, g_authid[id], value)
		}
		
		iCoin[id] = 0
}
public client_putinserver(iPlayer) {
		set_task(60.0*Kac_Dakikada_Bir,"@GiveCoin",iPlayer+779933);
		@SetUserHat(iPlayer,0);
}

public CmdGiveCoin(index, level, command)
{
		if (!cmd_access(index, level, command, 3))
		{
				return PLUGIN_HANDLED
		}

		new arg_player[64]
		read_argv(1, arg_player, charsmax(arg_player))
		new player = cmd_target(index, arg_player, CMDTARGET_ALLOW_SELF)

		if (!player)
		{
			return PLUGIN_HANDLED
		}

		new amount = read_argv_int(2)

		if (amount < 0)
		{
			amount = -amount
		}

		iCoin[player] += amount

		new name[35], player_name[35]
		get_user_name(index, name, charsmax(name))
		get_user_name(player, player_name, charsmax(player_name))
		show_activity(index, name, "give %d coin(s) to %s", amount, player_name)

		return PLUGIN_HANDLED
}

public CmdTakeCoin(index, level, command)
{
		if (!cmd_access(index, level, command, 3))
		{
				return PLUGIN_HANDLED
		}

		new arg_player[64]
		read_argv(1, arg_player, charsmax(arg_player))
		new player = cmd_target(index, arg_player, CMDTARGET_ALLOW_SELF)

		if (!player)
		{
			return PLUGIN_HANDLED
		}

		new amount = read_argv_int(2)

		if (amount < 0)
		{
			amount = -amount
		}

		iCoin[player] -= amount

		if (iCoin[player] < 0)
		{
			iCoin[player] = 0
		}

		new name[35], player_name[35]
		get_user_name(index, name, charsmax(name))
		get_user_name(player, player_name, charsmax(player_name))
		show_activity(index, name, "take %d coin(s) from %s", amount, player_name)

		return PLUGIN_HANDLED
}


@GiveCoin(const iTaskID) {
		new iPlavyer = iTaskID-779933;
		if(is_user_connected(iPlavyer)) {
				iCoin[iPlavyer] += 10;
				set_task(60.0*Kac_Dakikada_Bir,"@GiveCoin",iPlavyer+779933);
				client_print_color(iPlavyer, iPlavyer, "^1[ ^3- ^4%s ^3- ^1] ^1Sunucuda %i dakika durdugunuz icin 10 Coin kazandiniz.",sTag,floatround(60.0*Kac_Dakikada_Bir))
		}
}
@TakeDamage(const pVictim, const pInflictor, const pAttacker, Float:flDamage, bitsDamageType) {
		if(!is_user_connected(pAttacker) || !rg_is_player_can_takedamage(pVictim, pAttacker) || pVictim == pAttacker) return;
 
		iCoin[pAttacker] += random_num(1,5);
}
@OpenHatMenu(const iPlayer) {
		if (!is_user_alive(iPlayer))
		{
				client_print_color(iPlayer, iPlayer, "^1[ ^3- ^4%s ^3- ^1] ^1You can't use that now.", sTag)
				return
		}
		new Menu = menu_create(fmt("\d( \r%s \d) \y~> Sapka Menüsü \y~> \wSizdeki Coin: \r%i",sTag,iCoin[iPlayer]), "@OpenHatMenu_");
		menu_additem(Menu,fmt("\r[\y%s\r] \d~> \wSapkayi \rCikar^n",sTag),"333");
		for(new fMenu=1;fMenu<sizeof(sHats);fMenu++)
				menu_additem(Menu,fmt("\r[\y%s\r] \d~> \w%s \d[\w%d \yCoin\d]", sTag,sHats[fMenu][0][0],sHats[fMenu][2][0]),fmt("%i",fMenu));
		menu_setprop(Menu, MPROP_BACKNAME,"Önceki Sayfa"),menu_setprop(Menu, MPROP_NEXTNAME,"Sonraki Sayfa"),menu_setprop(Menu, MPROP_EXITNAME,"\wKapat");
		menu_display(iPlayer, Menu);
}
@OpenHatMenu_(const iPlayer,const iMenu, const iItem) {
		if(iItem == MENU_EXIT || !is_user_alive(iPlayer)) { menu_destroy(iMenu);return PLUGIN_HANDLED; }
		new iData[6], iKey;
		menu_item_getinfo(iMenu, iItem, _, iData, charsmax(iData));
		iKey = str_to_num(iData);
		if(iKey == 333) {
				@SetUserHat(iPlayer,0);
				menu_destroy(iMenu);return PLUGIN_HANDLED;
		}
		if(iCoin[iPlayer] >= sHats[iKey][2][0]) {
			   // iCoin[iPlayer] -= sHats[iKey][2][0];
				@SetUserHat(iPlayer,0),@SetUserHat(iPlayer,iKey);
		}
		else client_print_color(iPlayer, iPlayer, "^1[ ^3- ^4%s ^3- ^1] ^1Yeterli paraniz bulunmuyor! Gereken: ^3%i ^4Coin",sTag,sHats[iKey][2][0]-iCoin[iPlayer]),@OpenHatMenu(iPlayer)
		menu_destroy(iMenu);return PLUGIN_HANDLED;
}
@SetUserHat(const iPlayer, const iHatNum) {
		switch(iHatNum) {
				case 0: {
						iHatEnt[iPlayer] > 0 ? rg_remove_entity(iHatEnt[iPlayer]):(iHatEnt[iPlayer] = 0);
				}
				default: {
						iHatEnt[iPlayer] = rg_create_entity("info_target");
						set_entvar(iHatEnt[iPlayer],var_movetype,MOVETYPE_FOLLOW);
						set_entvar(iHatEnt[iPlayer],var_aiment,iPlayer);
						set_entvar(iHatEnt[iPlayer],var_rendermode,kRenderNormal);
						set_entvar(iHatEnt[iPlayer],var_modelindex,iHatModels[iHatNum]);
				}
		}
}
rg_remove_entity(const iEnt){
		if(is_entity(iEnt))
				set_entvar(iEnt,var_flags,FL_KILLME);
}
__________________









Last edited by CrazY.; 10-18-2021 at 08:40.
CrazY. is offline
Erra
Member
Join Date: Jun 2021
Old 10-18-2021 , 09:27   Re: hello, this hat system gives coins at a certain time, but when the map changes, t
Reply With Quote #18

Quote:
Originally Posted by CrazY. View Post
There you go.

Commands:
amx_coin "player name or #userid" amount - give coin to a player
amx_takecoin "player name or #userid" amount - take coin from a player

Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <reapi>
#define Kac_Dakikada_Bir 5

new const sTag[] = "GitHub";

new g_vault

new const sHats[][][] = { {"","",0},
		{"Dede Sapkasi","models/hat/dede.mdl",100},
		{"Suratsiz Sapkasi","models/hat/suratsiz.mdl",100},
		{"Inek Sapkasi","models/hat/inek.mdl",200},
		{"Palyaco Sapkasi","models/hat/palyaco.mdl",300},
		{"Kedi Sapkasi","models/hat/kedi.mdl",400},
		{"Korku Sapkasi","models/hat/korku.mdl",700}
};
new iHatModels[sizeof(sHats)+1],iHatEnt[MAX_PLAYERS+1],iCoin[MAX_PLAYERS+1];
new g_authid[MAX_PLAYERS+1][MAX_AUTHID_LENGTH]
public plugin_precache() {
		for(new i=1; i < sizeof(sHats);i++)
				iHatModels[i] = precache_model(sHats[i][1][0]);
}
public plugin_natives() {
		register_native("nGetUserCoin","@NTV_CN");
}
@NTV_CN() {
		new iJlayer = get_param(1);
		return iCoin[iJlayer];
}
public plugin_init() {
		register_plugin("Sapka Menü", "1.0", "PawNod'");
 
		register_clcmd("say /sapka","@OpenHatMenu");
		register_clcmd("say /hat","@OpenHatMenu");

		register_concmd("amx_coin", "CmdGiveCoin")
		register_concmd("amx_takecoin", "CmdTakeCoin")

		g_vault = nvault_open("coins")
}

public plugin_end()
{
		if (g_vault != INVALID_HANDLE)
				nvault_close(g_vault)
}
public client_authorized(id, const authid[])
{
		if (!is_user_bot(id) && !is_user_hltv(id) && g_vault != INVALID_HANDLE)
		{
				copy(g_authid[id], charsmax(g_authid[]), authid)
				iCoin[id] = nvault_get(g_vault, authid)
		}
}
public client_disconnected(id)
{

		if (!is_user_bot(id) && !is_user_hltv(id) && g_vault != INVALID_HANDLE)
		{
				new value[32]
				formatex(value, charsmax(value), "%d", iCoin[id])
				nvault_set(g_vault, g_authid[id], value)
		}
		
		iCoin[id] = 0
}
public client_putinserver(iPlayer) {
		set_task(60.0*Kac_Dakikada_Bir,"@GiveCoin",iPlayer+779933);
		@SetUserHat(iPlayer,0);
}

public CmdGiveCoin(index, level, command)
{
		if (!cmd_access(index, level, command, 3))
		{
				return PLUGIN_HANDLED
		}

		new arg_player[64]
		read_argv(1, arg_player, charsmax(arg_player))
		new player = cmd_target(index, arg_player, CMDTARGET_ALLOW_SELF)

		if (!player)
		{
			return PLUGIN_HANDLED
		}

		new amount = read_argv_int(2)

		if (amount < 0)
		{
			amount = -amount
		}

		iCoin[player] += amount

		new name[35], player_name[35]
		get_user_name(index, name, charsmax(name))
		get_user_name(player, player_name, charsmax(player_name))
		show_activity(index, name, "give %d coin(s) to %s", amount, player_name)

		return PLUGIN_HANDLED
}

public CmdTakeCoin(index, level, command)
{
		if (!cmd_access(index, level, command, 3))
		{
				return PLUGIN_HANDLED
		}

		new arg_player[64]
		read_argv(1, arg_player, charsmax(arg_player))
		new player = cmd_target(index, arg_player, CMDTARGET_ALLOW_SELF)

		if (!player)
		{
			return PLUGIN_HANDLED
		}

		new amount = read_argv_int(2)

		if (amount < 0)
		{
			amount = -amount
		}

		iCoin[player] -= amount

		if (iCoin[player] < 0)
		{
			iCoin[player] = 0
		}

		new name[35], player_name[35]
		get_user_name(index, name, charsmax(name))
		get_user_name(player, player_name, charsmax(player_name))
		show_activity(index, name, "take %d coin(s) from %s", amount, player_name)

		return PLUGIN_HANDLED
}


@GiveCoin(const iTaskID) {
		new iPlavyer = iTaskID-779933;
		if(is_user_connected(iPlavyer)) {
				iCoin[iPlavyer] += 10;
				set_task(60.0*Kac_Dakikada_Bir,"@GiveCoin",iPlavyer+779933);
				client_print_color(iPlavyer, iPlavyer, "^1[ ^3- ^4%s ^3- ^1] ^1Sunucuda %i dakika durdugunuz icin 10 Coin kazandiniz.",sTag,floatround(60.0*Kac_Dakikada_Bir))
		}
}
@TakeDamage(const pVictim, const pInflictor, const pAttacker, Float:flDamage, bitsDamageType) {
		if(!is_user_connected(pAttacker) || !rg_is_player_can_takedamage(pVictim, pAttacker) || pVictim == pAttacker) return;
 
		iCoin[pAttacker] += random_num(1,5);
}
@OpenHatMenu(const iPlayer) {
		if (!is_user_alive(iPlayer))
		{
				client_print_color(iPlayer, iPlayer, "^1[ ^3- ^4%s ^3- ^1] ^1You can't use that now.", sTag)
				return
		}
		new Menu = menu_create(fmt("\d( \r%s \d) \y~> Sapka Menüsü \y~> \wSizdeki Coin: \r%i",sTag,iCoin[iPlayer]), "@OpenHatMenu_");
		menu_additem(Menu,fmt("\r[\y%s\r] \d~> \wSapkayi \rCikar^n",sTag),"333");
		for(new fMenu=1;fMenu<sizeof(sHats);fMenu++)
				menu_additem(Menu,fmt("\r[\y%s\r] \d~> \w%s \d[\w%d \yCoin\d]", sTag,sHats[fMenu][0][0],sHats[fMenu][2][0]),fmt("%i",fMenu));
		menu_setprop(Menu, MPROP_BACKNAME,"Önceki Sayfa"),menu_setprop(Menu, MPROP_NEXTNAME,"Sonraki Sayfa"),menu_setprop(Menu, MPROP_EXITNAME,"\wKapat");
		menu_display(iPlayer, Menu);
}
@OpenHatMenu_(const iPlayer,const iMenu, const iItem) {
		if(iItem == MENU_EXIT || !is_user_alive(iPlayer)) { menu_destroy(iMenu);return PLUGIN_HANDLED; }
		new iData[6], iKey;
		menu_item_getinfo(iMenu, iItem, _, iData, charsmax(iData));
		iKey = str_to_num(iData);
		if(iKey == 333) {
				@SetUserHat(iPlayer,0);
				menu_destroy(iMenu);return PLUGIN_HANDLED;
		}
		if(iCoin[iPlayer] >= sHats[iKey][2][0]) {
			   // iCoin[iPlayer] -= sHats[iKey][2][0];
				@SetUserHat(iPlayer,0),@SetUserHat(iPlayer,iKey);
		}
		else client_print_color(iPlayer, iPlayer, "^1[ ^3- ^4%s ^3- ^1] ^1Yeterli paraniz bulunmuyor! Gereken: ^3%i ^4Coin",sTag,sHats[iKey][2][0]-iCoin[iPlayer]),@OpenHatMenu(iPlayer)
		menu_destroy(iMenu);return PLUGIN_HANDLED;
}
@SetUserHat(const iPlayer, const iHatNum) {
		switch(iHatNum) {
				case 0: {
						iHatEnt[iPlayer] > 0 ? rg_remove_entity(iHatEnt[iPlayer]):(iHatEnt[iPlayer] = 0);
				}
				default: {
						iHatEnt[iPlayer] = rg_create_entity("info_target");
						set_entvar(iHatEnt[iPlayer],var_movetype,MOVETYPE_FOLLOW);
						set_entvar(iHatEnt[iPlayer],var_aiment,iPlayer);
						set_entvar(iHatEnt[iPlayer],var_rendermode,kRenderNormal);
						set_entvar(iHatEnt[iPlayer],var_modelindex,iHatModels[iHatNum]);
				}
		}
}
rg_remove_entity(const iEnt){
		if(is_entity(iEnt))
				set_entvar(iEnt,var_flags,FL_KILLME);
}

Will the tokens be spent and will players be able to access the menu while dead?
and eternal gratitude
Erra is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-18-2021 , 09:28   Re: hello, this hat system gives coins at a certain time, but when the map changes, t
Reply With Quote #19

Quote:
Originally Posted by Erra View Post
I'm looking forward to it sir
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <reapi>
#include <nvault>

#define TASK_FREE_COINS 779933
#define Kac_Dakikada_Bir 5

#if AMXX_VERSION_NUM > 182
#define client_disconnect client_disconnected
#endif

new const g_szTAG[] = "GitHub";

enum ENUM_HATS_DATA(+=1)
{
        
HAT_NAME[32],
        
HAT_MODEL[64],
        
HAT_PRICE
}

new const 
g_aHATS_DATA[][ENUM_HATS_DATA] = {
        { 
"Dede Sapkasi""models/hat/dede.mdl"100 },
        { 
"Suratsiz Sapkasi""models/hat/suratsiz.mdl"100 },
        { 
"Inek Sapkasi""models/hat/inek.mdl"200 },
        { 
"Palyaco Sapkasi""models/hat/palyaco.mdl"300 },
        { 
"Kedi Sapkasi""models/hat/kedi.mdl"400 },
        { 
"Korku Sapkasi""models/hat/korku.mdl"700 }
};

new     
g_pHats_Model_index[sizeof g_aHATS_DATA],
        
g_bHatAlreadyBeenBought[MAX_PLAYERS+1][sizeof g_aHATS_DATA],
        
g_iHat_Ent[MAX_PLAYERS+1],
        
g_iCoin[MAX_PLAYERS+1],
        
bool:g_bUserConnected[MAX_PLAYERS+1],
        
g_Coins_nVault INVALID_HANDLE;

public 
plugin_precache()
{
        for(new 
imaxloop sizeof g_aHATS_DATAmaxloopi++)
        {
                
g_pHats_Model_index[i] = precache_modelg_aHATS_DATA[i][HAT_MODEL] );
        }
}
public 
plugin_natives()
{
        
register_native("nGetUserCoin""NTV_CN");
}

public 
NTV_CN(pluginargc)
{
        new 
iPlayer get_param(1);

        if(!
g_bUserConnected[iPlayer])
        {
                
log_error(AMX_ERR_GENERAL"Player #%d is not connected!"iPlayer);
                return 
0;
        }

        return 
g_iCoin[iPlayer];
}
public 
plugin_init()
{
        
register_plugin("Sapka Menü""1.0""Natsheh");
 
        
register_clcmd("say /sapka""OpenHatMenu");
        
register_clcmd("say_team /sapka""OpenHatMenu");

        
register_clcmd("say /hat""OpenHatMenu");
        
register_clcmd("say_team /hat""OpenHatMenu");

        
register_clcmd("say /hats""OpenHatMenu");
        
register_clcmd("say_team /hats""OpenHatMenu");

        
register_cvar("Hats_Menu_By_Natsheh""v1.0"FCVAR_SERVER|FCVAR_SPONLY);

        
register_concmd("amx_give_coins""concmd_give_coins"ADMIN_KICK"<name> < +|- value>")
}

public 
concmd_give_coins(idlevelcid)
{
        if(!
cmd_access(idlevelcid2))
        {
                return 
1;
        }

        new 
szTarget[32], szValue[12];
        
read_argv(1szTargetcharsmax(szTarget));
        
read_argv(2szValuecharsmax(szValue));
        
remove_quotes(szTarget);
        
remove_quotes(szValue);


        new 
player cmd_target(idszTargetCMDTARGET_ALLOW_SELF);

        if(!
player) return 1;

        if(!
strlen(szValue) || str_to_num(szValue) == 0)
        {
                
console_print(id"^n* amx_give_coins < name > < amount >");
                
console_print(id"* The 2nd argument ( amount ) is missing!^n");
                return 
1;
        }

        if(!
is_str_num(szValue))
        {
                
console_print(id"^n* amx_give_coins < name > < amount >");
                
console_print(id"* The 2nd argument ( amount ) must be numbers only!^n");
                return 
1;
        }

        
g_iCoinplayer ] += str_to_num(szValue);
        return 
1;
}

public 
client_putinserver(iPlayer)
{
        
g_iCoiniPlayer ] = 0;
        
g_bUserConnectediPlayer ] = true;

        if(
is_user_bot(iPlayer) || is_user_hltv(iPlayer)) return;

        if(
g_Coins_nVault == INVALID_HANDLE)
        {
                
g_Coins_nVault nvault_open("hats_players_coins");
        }

        if(
g_Coins_nVault != INVALID_HANDLE)
        {
                new 
szAuthID[32];
                
get_user_authid(iPlayerszAuthIDcharsmax(szAuthID));
                
g_iCoiniPlayer ] = nvault_get(g_Coins_nVaultszAuthID);

                
nvault_close(g_Coins_nVault);
                
g_Coins_nVault INVALID_HANDLE;
        }

        
set_task60.0 Kac_Dakikada_Bir"GiveCoin"iPlayer+TASK_FREE_COINS);
}

public 
client_disconnect(iPlayer)
{
        if(!
g_bUserConnectediPlayer ]) return;

        
SetUserHat(iPlayer,-1);
        
g_bUserConnectediPlayer ] = false;
        
arraysetg_bHatAlreadyBeenBoughtiPlayer ], falsesizeof g_bHatAlreadyBeenBought[] );

        if(
is_user_bot(iPlayer) || is_user_hltv(iPlayer)) return;

        if(
g_Coins_nVault == INVALID_HANDLE)
        {
                
g_Coins_nVault nvault_open("hats_players_coins");
        }

        if(
g_Coins_nVault != INVALID_HANDLE)
        {
                new 
szAuthID[32], szValue[12];
                
get_user_authid(iPlayerszAuthIDcharsmax(szAuthID));
                
num_to_str(g_iCoiniPlayer ], szValuecharsmax(szValue));
                
nvault_set(g_Coins_nVaultszAuthIDszValue);

                
nvault_close(g_Coins_nVault);
                
g_Coins_nVault INVALID_HANDLE;
        }
}

public 
GiveCoin(const iTaskID
{
        new 
iPlayer iTaskID-TASK_FREE_COINS;
        if(
g_bUserConnected[iPlayer])
        {
                
g_iCoin[iPlayer] += 10;
                
set_task60.0 Kac_Dakikada_Bir"GiveCoin"iPlayer TASK_FREE_COINS);
                
client_print_color(iPlayeriPlayer"^1[ ^3- ^4%s ^3- ^1] ^1Sunucuda %i dakika durdugunuz icin 10 Coin kazandiniz."g_szTAGfloatround(60.0*Kac_Dakikada_Bir))
        }
}

public 
TakeDamage(const pVictim, const pInflictor, const pAttackerFloat:flDamagebitsDamageType)
{
        if(!
g_bUserConnected[pAttacker]) || !rg_is_player_can_takedamage(pVictimpAttacker) || pVictim == pAttacker) return;
 
        
g_iCoin[pAttacker] += random_num(1,5);
}

public 
OpenHatMenu(const iPlayer)
{
        if(!
is_user_alive(iPlayer))
        {
                
client_print_color(iPlayeriPlayer"^1[ ^3- ^4%s ^3- ^1] ^1You must be alive in order to open the hats menu"g_szTAG);
                return;
        }

        new 
Menu menu_create(fmt("\d( \r%s \d) \y~> Sapka Menüsü \y~> \wSizdeki Coin: \r%i"g_szTAGg_iCoin[iPlayer]), "OpenHatMenu_");
        
        
menu_additem(Menu,fmt("\r[\y%s\r] \d~> \wSapkayi \rCikar^n"g_szTAG),"333");
        
        static 
maxloop 0; if(!maxloopmaxloop sizeof g_aHATS_DATA;

        for(new 
iMenuItemiMenuItem maxloop iMenuItem++)
        {
                if(
g_bHatAlreadyBeenBought[iPlayer][iMenuItem])
                        
menu_additem(Menufmt("\r[\y%s\r] \d~> \w%s"g_szTAGg_aHATS_DATA[iMenuItem][HAT_NAME]), fmt("%i",iMenuItem));
                else
                        
menu_additem(Menufmt("\r[\y%s\r] \d~> \w%s \d[\w%d \yCoin\d]"g_szTAGg_aHATS_DATA[iMenuItem][HAT_NAME], g_aHATS_DATA[iMenuItem][HAT_PRICE]), fmt("%i",iMenuItem));
        }

        
menu_setprop(MenuMPROP_BACKNAME,"Önceki Sayfa");
        
menu_setprop(MenuMPROP_NEXTNAME,"Sonraki Sayfa");
        
menu_setprop(MenuMPROP_EXITNAME,"\wKapat");
        
menu_display(iPlayerMenu);
}

public 
OpenHatMenu_(const iPlayer,const iMenu, const iItem)
{
        if(
iItem == MENU_EXIT)
        {
                
menu_destroy(iMenu);
                return 
PLUGIN_HANDLED;
        }

        if(!
is_user_alive(iPlayer))
        {
                
client_print_color(iPlayeriPlayer"^1[ ^3- ^4%s ^3- ^1] ^1You must be alive in order to use the hats menu"g_szTAG);
                
menu_destroy(iMenu);
                return 
PLUGIN_HANDLED;
        }

        new 
iData[6], iKey;
        
menu_item_getinfo(iMenuiItem_iDatacharsmax(iData));
        
iKey str_to_num(iData);

        if(
iKey == 333)
        {
                
SetUserHat(iPlayer,-1);
                
menu_destroy(iMenu);
                return 
PLUGIN_HANDLED;
        }

        if(
g_bHatAlreadyBeenBought[iPlayer][iKey])
        {
                
SetUserHat(iPlayer,-1);
                
SetUserHat(iPlayer,iKey);
        }
        else if(
g_iCoin[iPlayer] >= g_aHATS_DATA[iKey][HAT_PRICE])
        {
                
g_iCoin[iPlayer] -= g_aHATS_DATA[iKey][HAT_PRICE];
                
g_bHatAlreadyBeenBought[iPlayer][iKey] = true;
                
SetUserHat(iPlayer,-1);
                
SetUserHat(iPlayer,iKey);
        }
        else
        {
                
client_print_color(iPlayeriPlayer"^1[ ^3- ^4%s ^3- ^1] ^1Yeterli paraniz bulunmuyor! Gereken: ^3%i ^4Coin"g_szTAGg_aHATS_DATA[iKey][HAT_PRICE] - g_iCoin[iPlayer]);
                
OpenHatMenu(iPlayer);
        }

        
menu_destroy(iMenu);
        return 
PLUGIN_HANDLED;
}

public 
SetUserHat(const iPlayer, const iHatNum)
{
        switch(
iHatNum)
        {
                case -
1:
                {
                        if(
g_iHat_Ent[iPlayer] > 0rg_remove_entityg_iHat_Ent[iPlayer] );
                        
g_iHat_Ent[iPlayer] = 0;
                }
                default:
                {
                        
g_iHat_Ent[iPlayer] = rg_create_entity("info_target");
                        
set_entvar(g_iHat_Ent[iPlayer], var_movetypeMOVETYPE_FOLLOW);
                        
set_entvar(g_iHat_Ent[iPlayer], var_aimentiPlayer);
                        
set_entvar(g_iHat_Ent[iPlayer], var_rendermodekRenderNormal);
                        
set_entvar(g_iHat_Ent[iPlayer], var_modelindexg_aHATS_DATA[iHatNum][HAT_MODEL]);
                }
        }
}

rg_remove_entity(const iEnt)
{
        if(
is_entity(iEnt))
        {
                
set_entvar(iEnt,var_flags,FL_KILLME);
        }

Here you go...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-19-2021 at 00:13.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Erra
Member
Join Date: Jun 2021
Old 10-18-2021 , 09:36   Re: hello, this hat system gives coins at a certain time, but when the map changes, t
Reply With Quote #20

Quote:
Originally Posted by Natsheh View Post
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <reapi>
#include <nvault>

#define TASK_FREE_COINS 779933
#define Kac_Dakikada_Bir 5

#if AMXX_VERSION_NUM > 182
#define client_disconnect client_disconnected
#endif

new const g_szTAG[] = "GitHub";

enum ENUM_HATS_DATA(+=1)
{
        
HAT_NAME[32],
        
HAT_MODEL[64],
        
HAT_PRICE
}

new const 
g_aHATS_DATA[][ENUM_HATS_DATA] = {
        { 
"Dede Sapkasi""models/hat/dede.mdl"100 },
        { 
"Suratsiz Sapkasi""models/hat/suratsiz.mdl"100 },
        { 
"Inek Sapkasi""models/hat/inek.mdl"200 },
        { 
"Palyaco Sapkasi""models/hat/palyaco.mdl"300 },
        { 
"Kedi Sapkasi""models/hat/kedi.mdl"400 },
        { 
"Korku Sapkasi""models/hat/korku.mdl"700 }
};

new     
g_pHats_Model_index[sizeof g_aHATS_DATA],
        
g_bHatAlreadyBeenBought[MAX_PLAYERS+1][sizeof g_aHATS_DATA],
        
g_iHat_Ent[MAX_PLAYERS+1],
        
g_iCoin[MAX_PLAYERS+1],
        
g_bUserConnected[MAX_PLAYERS+1],
        
g_Coins_nVault INVALID_HANDLE;

public 
plugin_precache()
{
        for(new 
imaxloop sizeof g_aHATS_DATAmaxloopi++)
        {
                
g_pHats_Model_index[i] = precache_modelg_aHATS_DATA[i][HAT_MODEL] );
        }
}
public 
plugin_natives()
{
        
register_native("nGetUserCoin""NTV_CN");
}

public 
NTV_CN(pluginargc)
{
        new 
iPlayer get_param(1);

        if(!
is_user_connected(iPlayer))
        {
                
log_error(AMX_ERR_GENERAL"Player #%d is not connected!"iPlayer);
                return 
0;
        }

        return 
g_iCoin[iPlayer];
}
public 
plugin_init()
{
        
register_plugin("Sapka Menü""1.0""Natsheh");
 
        
register_clcmd("say /sapka""OpenHatMenu");
        
register_clcmd("say_team /sapka""OpenHatMenu");

        
register_clcmd("say /hat""OpenHatMenu");
        
register_clcmd("say_team /hat""OpenHatMenu");

        
register_clcmd("say /hats""OpenHatMenu");
        
register_clcmd("say_team /hats""OpenHatMenu");

        
register_cvar("Hats_Menu_By_Natsheh""v1.0"FCVAR_SERVER|FCVAR_SPONLY);

        
register_concmd("amx_give_coins""concmd_give_coins"ADMIN_KICK"<name> < +|- value>")
}

public 
concmd_give_coins(idlevelcid)
{
        if(!
cmd_access(idlevelcid2))
        {
                return 
1;
        }

        new 
szTarget[32], szValue[12];
        
read_argv(1szTargetcharsmax(szTarget));
        
read_argv(2szValuecharsmax(szValue));
        
remove_quotes(szTarget);
        
remove_quotes(szValue);


        new 
player cmd_target(idszTargetCMDTARGET_ALLOW_SELF);

        if(!
player) return 1;

        if(!
strlen(szValue) || str_to_num(szValue) == 0)
        {
                
console_print(id"^n* amx_give_coins < name > < amount >");
                
console_print(id"* The 2nd argument ( amount ) is missing!^n");
                return 
1;
        }

        if(!
is_str_num(szValue))
        {
                
console_print(id"^n* amx_give_coins < name > < amount >");
                
console_print(id"* The 2nd argument ( amount ) must be numbers only!^n");
                return 
1;
        }

        
g_iCoinplayer ] += str_to_num(szValue);
        return 
1;
}

public 
client_putinserver(iPlayer)
{
        
g_iCoiniPlayer ] = 0;
        
g_bUserConnectediPlayer ] = true;

        if(
is_user_bot(iPlayer) || is_user_hltv(iPlayer)) return;

        if(
g_Coins_nVault == INVALID_HANDLE)
        {
                
g_Coins_nVault nvault_open("hats_players_coins");
        }

        if(
g_Coins_nVault != INVALID_HANDLE)
        {
                new 
szAuthID[32];
                
get_user_authid(iPlayerszAuthIDcharsmax(szAuthID));
                
g_iCoiniPlayer ] = nvault_get(g_Coins_nVaultszAuthID);

                
nvault_close(g_Coins_nVault);
        }

        
set_task60.0 Kac_Dakikada_Bir"GiveCoin"iPlayer+TASK_FREE_COINS);
}

public 
client_disconnect(iPlayer)
{
        if(!
g_bUserConnectediPlayer ]) return;

        
SetUserHat(iPlayer,-1);
        
g_bUserConnectediPlayer ] = false;
        
arraysetg_bHatAlreadyBeenBoughtiPlayer ], falsesizeof g_bHatAlreadyBeenBought[] );

        if(
is_user_bot(iPlayer) || is_user_hltv(iPlayer)) return;

        if(
g_Coins_nVault == INVALID_HANDLE)
        {
                
g_Coins_nVault nvault_open("hats_players_coins");
        }

        if(
g_Coins_nVault != INVALID_HANDLE)
        {
                new 
szAuthID[32], szValue[12];
                
get_user_authid(iPlayerszAuthIDcharsmax(szAuthID));
                
num_to_str(g_iCoiniPlayer ], szValuecharsmax(szValue));
                
nvault_set(g_Coins_nVaultszAuthIDszValue);

                
nvault_close(g_Coins_nVault);
        }
}

public 
GiveCoin(const iTaskID
{
        new 
iPlayer iTaskID-TASK_FREE_COINS;
        if(
is_user_connected(iPlayer))
        {
                
g_iCoin[iPlayer] += 10;
                
set_task60.0 Kac_Dakikada_Bir"GiveCoin"iPlayer TASK_FREE_COINS);
                
client_print_color(iPlayeriPlayer"^1[ ^3- ^4%s ^3- ^1] ^1Sunucuda %i dakika durdugunuz icin 10 Coin kazandiniz."g_szTAGfloatround(60.0*Kac_Dakikada_Bir))
        }
}

public 
TakeDamage(const pVictim, const pInflictor, const pAttackerFloat:flDamagebitsDamageType)
{
        if(!
is_user_connected(pAttacker) || !rg_is_player_can_takedamage(pVictimpAttacker) || pVictim == pAttacker) return;
 
        
g_iCoin[pAttacker] += random_num(1,5);
}

public 
OpenHatMenu(const iPlayer)
{
        if(!
is_user_alive(iPlayer))
        {
                
client_print_color(iPlayeriPlayer"^1[ ^3- ^4%s ^3- ^1] ^1You must be alive in order to open the hats menu"g_szTAG);
                return;
        }

        new 
Menu menu_create(fmt("\d( \r%s \d) \y~> Sapka Menüsü \y~> \wSizdeki Coin: \r%i"g_szTAGg_iCoin[iPlayer]), "OpenHatMenu_");
        
        
menu_additem(Menu,fmt("\r[\y%s\r] \d~> \wSapkayi \rCikar^n"g_szTAG),"333");
        
        static 
maxloop 0; if(!maxloopmaxloop sizeof g_aHATS_DATA;

        for(new 
iMenuItemiMenuItem maxloop iMenuItem++)
        {
                if(
g_bHatAlreadyBeenBought[iPlayer][iMenuItem])
                        
menu_additem(Menufmt("\r[\y%s\r] \d~> \w%s"g_szTAGg_aHATS_DATA[iMenuItem][HAT_NAME]), fmt("%i",iMenuItem));
                else
                        
menu_additem(Menufmt("\r[\y%s\r] \d~> \w%s \d[\w%d \yCoin\d]"g_szTAGg_aHATS_DATA[iMenuItem][HAT_NAME], g_aHATS_DATA[iMenuItem][HAT_PRICE]), fmt("%i",iMenuItem));
        }

        
menu_setprop(MenuMPROP_BACKNAME,"Önceki Sayfa");
        
menu_setprop(MenuMPROP_NEXTNAME,"Sonraki Sayfa");
        
menu_setprop(MenuMPROP_EXITNAME,"\wKapat");
        
menu_display(iPlayerMenu);
}

public 
OpenHatMenu_(const iPlayer,const iMenu, const iItem)
{
        if(
iItem == MENU_EXIT)
        {
                
menu_destroy(iMenu);
                return 
PLUGIN_HANDLED;
        }

        if(!
is_user_alive(iPlayer))
        {
                
client_print_color(iPlayeriPlayer"^1[ ^3- ^4%s ^3- ^1] ^1You must be alive in order to use the hats menu"g_szTAG);
                
menu_destroy(iMenu);
                return 
PLUGIN_HANDLED;
        }

        new 
iData[6], iKey;
        
menu_item_getinfo(iMenuiItem_iDatacharsmax(iData));
        
iKey str_to_num(iData);

        if(
iKey == 333)
        {
                
SetUserHat(iPlayer,-1);
                
menu_destroy(iMenu);
                return 
PLUGIN_HANDLED;
        }

        if(
g_bHatAlreadyBeenBought[iPlayer][iKey])
        {
                
SetUserHat(iPlayer,-1);
                
SetUserHat(iPlayer,iKey);
        }
        else if(
g_iCoin[iPlayer] >= g_aHATS_DATA[iKey][HAT_PRICE])
        {
                
g_iCoin[iPlayer] -= g_aHATS_DATA[iKey][HAT_PRICE];
                
g_bHatAlreadyBeenBought[iPlayer][iKey] = true;
                
SetUserHat(iPlayer,-1);
                
SetUserHat(iPlayer,iKey);
        }
        else
        {
                
client_print_color(iPlayeriPlayer"^1[ ^3- ^4%s ^3- ^1] ^1Yeterli paraniz bulunmuyor! Gereken: ^3%i ^4Coin"g_szTAGg_aHATS_DATA[iKey][HAT_PRICE] - g_iCoin[iPlayer]);
                
OpenHatMenu(iPlayer);
        }

        
menu_destroy(iMenu);
        return 
PLUGIN_HANDLED;
}

public 
SetUserHat(const iPlayer, const iHatNum)
{
        switch(
iHatNum)
        {
                case -
1:
                {
                        if(
g_iHat_Ent[iPlayer] > 0rg_remove_entityg_iHat_Ent[iPlayer] );
                        
g_iHat_Ent[iPlayer] = 0;
                }
                default:
                {
                        
g_iHat_Ent[iPlayer] = rg_create_entity("info_target");
                        
set_entvar(g_iHat_Ent[iPlayer], var_movetypeMOVETYPE_FOLLOW);
                        
set_entvar(g_iHat_Ent[iPlayer], var_aimentiPlayer);
                        
set_entvar(g_iHat_Ent[iPlayer], var_rendermodekRenderNormal);
                        
set_entvar(g_iHat_Ent[iPlayer], var_modelindexiHatModels[iHatNum]);
                }
        }
}

rg_remove_entity(const iEnt)
{
        if(
is_entity(iEnt))
        {
                
set_entvar(iEnt,var_flags,FL_KILLME);
        }

Here you go...
eternal gratitude sir
Erra 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 23:59.


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