#include < amxmodx >
#include < engine >
#include < cstrike >
#include < hamsandwich >
#include < fun >
#include < fakemeta >
#include < nvault >
#define PREFIX "PontertSapka"
new const sapkaMODEL[ CsTeams ][ ] = {
"",
"models/pirossapi.mdl",
"models/keksapi.mdl",
""
};
new Sapka[ 33 ];
new pont[ 33 ]
new vault
public plugin_init() {
register_plugin( "Mikulás Sapka Pontért", "1.0", "Levii @ Peace" );
register_clcmd("say /sapka","sapka_menu")
register_event( "TeamInfo", "EventTeamInfo", "a" );
set_task(25.0, "KorUzenet", 0, _, _, "b")
vault = nvault_open("sapka_mentes");
}
public KorUzenet() {
print_color(0, "!g[%s]!y Mikulás Sapka Pontért, !gHasználat: !t/sapka !gKészítette: !tLevii @ Peace.",PREFIX)
return PLUGIN_HANDLED;
}
public plugin_precache( )
{
precache_model( sapkaMODEL[ CS_TEAM_T ] );
precache_model( sapkaMODEL[ CS_TEAM_CT ] );
}
public client_disconnect( id )
if( is_valid_ent( Sapka[ id ] ) )
remove_entity( Sapka[ id ])
public FwdHamPlayerSpawn( const id )
{
if( is_user_alive( id ) ) {
new egyseg = Sapka[ id ];
if( !is_valid_ent( egyseg ) ) {
if( !( egyseg = Sapka[ id ] = create_entity( "info_target" ) ) )
return;
new CsTeams:csapat = cs_get_user_team( id );
if( csapat != CS_TEAM_T && csapat != CS_TEAM_CT )
csapat = CS_TEAM_T;
entity_set_model( egyseg, sapkaMODEL[ csapat ] );
entity_set_int( egyseg, EV_INT_movetype, MOVETYPE_FOLLOW );
entity_set_edict( egyseg, EV_ENT_aiment, id );
}
}
}
public EventTeamInfo( ) {
new id = read_data( 1 ), egyseg = Sapka[ id ];
if( !is_valid_ent( egyseg ) ) {
if( egyseg > 0 )
Sapka[ id ] = 0;
return;
}
new szTeam[ 2 ];
read_data( 2, szTeam, 1 );
if( szTeam[ 0 ] == 'C' )
entity_set_model( egyseg, sapkaMODEL[ CS_TEAM_CT ] );
else
entity_set_model( egyseg, sapkaMODEL[ CS_TEAM_T ] );
}
public sapka_menu(id)
{
new cim[ 121 ]
format(cim, charsmax(cim), "\rPontért Sapka vétel ^n \dKészítette: \rLevii @ Peace^n Pontok: %d",pont[id])
new menu = menu_create(cim, "sapka_h" )
if(Sapka[id] == 0)
menu_additem(menu,"\yMikulás Sapka \d[\rElérve\d]","1",0)
else
menu_additem(menu,"\yMikulás Sapka \d[\r1200 Pont\d]","1",0)
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
}
public sapka_h(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[9], szName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
new key = str_to_num(data);
switch(key)
{
case 1:{
if(pont[id] >= 1200)
{
pont[id] -= 1200
Sapka[id] = 1
print_color(id, "!g[Információ]!y Sikeres vásárlás.")
}
else
{
print_color(id, "!g[Információ]!y Nincs elég pontod.")
}
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
public death(id)
{
new killer = read_data(1)
new victim = read_data(2)
if(killer == victim)
return PLUGIN_HANDLED
pont[killer]++
return PLUGIN_HANDLED
}
public mentes(id)
{
new vaultkey[64],vaultdata[256], authid[32]
get_user_authid(id, authid, 31)
format(vaultkey,63,"%s-SKIN", authid)
format(vaultdata,255,"%i#%i#",pont[id],Sapka[id])
nvault_set(vault,vaultkey,vaultdata)
return PLUGIN_CONTINUE
}
public betoltes(id)
{
new vaultkey[64],vaultdata[256], authid[32]
get_user_authid(id, authid, 31)
format(vaultkey,63,"%s-SKIN", authid)
format(vaultdata,255,"%i#%i#",pont[id],Sapka[id])
nvault_get(vault,vaultkey,vaultdata,255)
replace_all(vaultdata, 255, "#", " ")
new str_num[32], skin_num[32]
parse(vaultdata, str_num, 31, skin_num, 31)
pont[id] = str_to_num(str_num)
Sapka[id] = str_to_num(skin_num)
return PLUGIN_CONTINUE
}
public client_disconnect(id)
{
mentes(id)
}
public client_connect(id)
{
betoltes(id)
}
stock print_color(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!y", "^1")
replace_all(msg, 190, "!t", "^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, get_user_msgid("SayText"), _, players[i])
write_byte(players[i])
write_string(msg)
message_end()
}
}
}
return PLUGIN_HANDLED
}