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

Optimize code and add little code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MITAR
Junior Member
Join Date: Sep 2018
Old 02-27-2019 , 11:00   Optimize code and add little code
Reply With Quote #1

Add menu buy skins with point system

Add to points_shop (id) option to buy points with "$" and buy revive

TIME ON SERVER = x points Possible alteration by cvar

optimize code

solve bug when added many points the player gets negative points

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <hamsandwich>
#include <fakemeta_util>
#include <engine>
#include <cstrike>
#include <fun>
#include <time>
#include <colorchat>

#pragma tabsize 0

#define ADMIN_ACCESS ADMIN_IMMUNITY

#define PREFIX "LOJA"

#define FALL_VELOCITY 350.0 //NO FALL DAMAGE

/*-------------- Plugin Information --------------*/

#define PLUGIN "Gold System"
#define VERSION "1.0"
#define AUTHOR "EaGle07 & Freezo & SeMnOmE"

/*-------------- Stock Cvars --------------*/
new gVault, gSteamID[ 32 ],vKey[ 64 ],vData[ 64 ];
new gPontosystem;
new gPontos [ 33 ];
new g_iTarget [33];
new gShop
new gGrenades
new gSilentcost
new gHealthcost
new pHealth
new gArmorcost
new pArmor
new gGravitycost
new gSpeedcost
new gInvisiblecost
new gBhopcost
new gGlowcost
new pSpeed
new gGravity
new gPontosbonus
new gJail

new hasGrenades [ 33 ];
new hasSilent [ 33 ];
new hasHealth [ 33 ];
new hasArmor [ 33 ];
new hasGravity [ 33 ];
new hasSpeed [ 33 ];
new hasInvisible [ 33 ];
new hasBhop [ 33 ];
new hasGlow [ 33 ];
new bhopOn [ 33 ];

new hasJail [ 33 ];

new cvar_on
new entlist[][] = {
"func_button",
"trigger_multiple",
"trigger_once"
}
//-------------- NO CRASH SERVER --------------//
new const gBlockcmd[][]=
{
"#Cstrike_GIGN_Label",
"#Cstrike_Spetsnaz_Label",
"@ #Cstrike_Spetsnaz_Label",
"#1Cstike",
"#",
"*",
"%"
}

new g_HudSterVVVXXXxyz;
const PEV_SPEC_TARGET = pev_iuser2;

//-------------- camUFLAGE --------------//
new CamoCost = 0

new bool:HasCamo[33]

new CTModels[] =
{
"urban", "gsg9",
"gign", "sas"
}

new TModels[] =
{
"terror", "leet",
"artic", "guerilla"
}

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

//-------------- Register Clcmd --------------//
register_clcmd( "say /loja", "pontos_Menu" );
register_clcmd( "say loja", "pontos_Menu" );
//register_clcmd( "say /pontos", "cmd_showPontos" );
//register_clcmd( "say pontos", "cmd_showPontos" );
register_clcmd( "donate", "CmdDonate" );
//register_clcmd("say /camouflage", "cmd_camouflage")
//register_clcmd("say_team /camouflage", "cmd_camouflage")
register_cvar("amxx_camouflage", "1")


//-------------- Register Event --------------//

register_logevent( "logevent_round_start", 2, "1=Round_Start" );
register_event( "DeathMsg", "Hook_Deathmessage", "a" );
register_event("ResetHUD", "ResetHud", "a"); //-camuflagem
//-------------- hud --------------//
register_event("ResetHUD", "event_ResetHud", "be");
// Forwards
RegisterHam(Ham_Killed, "player", "ham_PlayerKilled");
RegisterHam(Ham_Spawn, "player", "ham_PlayerSpawned_Post", 1);
// Hudmessage
g_HudSterVVVXXXxyz = CreateHudSyncObj();

//--------- Cmd for Set / reset Pontos --------//

register_concmd( "dar_pontos", "cmd_set", ADMIN_ACCESS, "<STEAM ID> <Pontos> DAR PONTOS" );
register_concmd( "reset_pontos", "cmd_reset", ADMIN_ACCESS, "<STEAM ID> <Pontos> - reset pontos" );

//-------------- Register Cvars --------------//

gPontosystem = register_cvar( "pontos_system", "1" ); /* 0 : Plugin disabled // 1 : plugin enabled */
gShop = register_cvar( "pontos_shop" , "1"); /* 0 : Shop disabled // 1 : Shop Enabled */
gPontosbonus = register_cvar( "pontos_bonus", "3") /* Bônus Pontos quando você mata um inimigo */
gJail = register_cvar( "jail_cost" , "15" ); /* jail Cost */
gGrenades = register_cvar( "grenades_cost" , "9" ); /* Grenades Pack Cost */
pHealth = register_cvar( "health_point", "200" ); /* Health Point Cvar */
pArmor = register_cvar( "armor_point", "200" ); /* Armor Point Cvar */
gGravity = register_cvar( "gravity_power", "0.3" ); /* Gravity Power Cvar */
pSpeed = register_cvar( "speed_power", "800.0"); /* Speed Power Cvar */
// ----------------- Cvar With cost ------------//
gSilentcost = register_cvar( "silent_cost", "50" ); /* Camuflagem Cost */
gHealthcost = register_cvar( "health_cost", "50" ); /* Health Cost */
gArmorcost = register_cvar( "armor_cost", "60" ); /* Armor Cost */
gGravitycost = register_cvar( "gravity_cost", "150" ); /* Gravity Cost */
gSpeedcost = register_cvar( "speed_cost", "125" ); /* Speed Cost */
gInvisiblecost = register_cvar( "invisible_cost","120" ); /* Invisible Cost */
gBhopcost = register_cvar( "bhop_cost", "5"); /* Faster Bunny Hop Cost */
gGlowcost = register_cvar( "glow_cost", "3") /* Random Glow Cost */

// ----------------- JAIL ------------//
cvar_on = register_cvar("open_jail_on","1")

}

/* ---| When client is connecting |--- */

public client_connect( id )
{
load_Pontos( id );
bhopOn[id] = false
HasCamo[id] = false
}
/* ---| When client has disconnected |--- */
public client_disconnect( id )
{
save_Pontos( id );
bhopOn[id] = false
}
/* ---| pontos Menu |--- */
public pontos_Menu(id)
{
if( get_pcvar_num( gPontosystem ) != 1 )
{
client_print( id, print_chat, "[%s] Sistema desligado!", PREFIX );
return PLUGIN_HANDLED;
}

new InfoStatus[198];
formatex( InfoStatus, charsmax( InfoStatus ), "[ MENU ]");
new menu = menu_create( InfoStatus, "gold_handler" );

formatex(InfoStatus, charsmax(InfoStatus), "[ LOJA ] \y[\rTu tens %d Pontos\y]", gPontos[id] );
menu_additem( menu, InfoStatus, "1", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ TOP 15 ]");
menu_additem( menu, InfoStatus, "2", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ RANK ]");
menu_additem( menu, InfoStatus, "3", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ Ver Pontos ]");
menu_additem( menu, InfoStatus, "4", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ Doar ]");
menu_additem( menu, InfoStatus, "5", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ RS ]");
menu_additem( menu, InfoStatus, "6", 0 );




menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );

menu_display( id, menu, 0 );

return PLUGIN_CONTINUE;

}

/* ---| pontos Menu Handler |--- */

public gold_handler( id, menu, item )
{
if( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
new szData[6];
new iAccess, hCallback;

menu_item_getinfo( menu, item, iAccess, szData, 5, _, _, hCallback );

new name[32]
get_user_name(id,name,32)

switch( str_to_num( szData ) )
{
case 1: pontos_shop(id)
case 2: client_cmd(id, "say /top15")
case 3: client_cmd(id, "say /rank")
case 4: ShowPoints(id)
case 5: Donate_Menu(id)
case 6: reset_score(id)


}

return PLUGIN_HANDLED;
}

/* ---| pontos Shop with items |--- */

public pontos_shop(id)
{
/* ---| if shop disabled player can't open the shop|--- */
if( get_pcvar_num( gShop ) != 1 )
{
client_print( id, print_chat, "[%s] DESLIGADO!", PREFIX );
return PLUGIN_HANDLED;
}

new InfoStatus[198];
formatex( InfoStatus, charsmax( InfoStatus ), "[ LOJA ] ^n Tens %d Pontos", gPontos[id] );

new menu = menu_create( InfoStatus, "shop_handler" );



formatex(InfoStatus, charsmax(InfoStatus), "[ Jail ]\r[ %d Pontos ]", get_pcvar_num( gGrenades ) );
menu_additem( menu, InfoStatus, "1", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ Granadas ]\r[ %d Pontos ]", get_pcvar_num( gGrenades ) );
menu_additem( menu, InfoStatus, "2", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ Camuflagem ]\r[ %d Pontos ]",get_pcvar_num( gSilentcost ));
menu_additem( menu, InfoStatus, "3", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ %d HP ]\r[ %d Pontos ]",get_pcvar_num( pHealth ) ,get_pcvar_num( gHealthcost ) );
menu_additem( menu, InfoStatus, "4", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ %d AP ]\r[ %d Pontos ]",get_pcvar_num( pArmor ) ,get_pcvar_num( gArmorcost ) );
menu_additem( menu, InfoStatus, "5", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ Gravidade ]\r[ %d Pontos ]",get_pcvar_num( gGravitycost ) );
menu_additem( menu, InfoStatus, "6", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ Velocidade ]\r[ %d Pontos ]",get_pcvar_num( gSpeedcost ) );
menu_additem( menu, InfoStatus, "7", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ Invisibilidade ]\r[ %d Pontos ]",get_pcvar_num( gInvisiblecost ) );
menu_additem( menu, InfoStatus, "8", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ 12500$ ]\r[ %d Pontos ]",get_pcvar_num( gBhopcost ) );
menu_additem( menu, InfoStatus, "9", 0 );

formatex(InfoStatus, charsmax(InfoStatus), "[ Glow ]\r[ %d Pontos ]",get_pcvar_num( gGlowcost ) );
menu_additem( menu, InfoStatus, "10", 0 );


menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );

menu_display( id, menu, 0 );

return PLUGIN_CONTINUE;

}

/* ---| pontos Shop Handler |--- */

public shop_handler(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}

new data[ 6 ], iName[ 64 ], access, callback;
menu_item_getinfo( menu, item, access, data, charsmax( data ), iName, charsmax( iName ), callback );

new key = str_to_num( data );

new Pontos = gPontos[ id ];

switch( key )
{

case 1://////////////////////////////////////////////////////////////////////////////////////////////////////////
{
if( hasJail[id])
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu ja compraste ^4Pack Grenades ", PREFIX);
return PLUGIN_HANDLED;
}

if( Pontos < get_pcvar_num( gJail ))
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Nao tens suficientes ^4Pontos ^1para comprar este item! ", PREFIX);
return PLUGIN_HANDLED;
}
else
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu abriste ^4a Jail", PREFIX);
open_jail(id)
gPontos[id] -= get_pcvar_num( gJail )
}
}

case 2:
{
if( hasGrenades[id])
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu ja compraste ^4Pack Grenades ", PREFIX);
return PLUGIN_HANDLED;
}

if( Pontos < get_pcvar_num( gGrenades ))
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Nao tens suficientes ^4Pontos ^1para comprar este item! ", PREFIX);
return PLUGIN_HANDLED;
}
else
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu compraste ^4Pack Grenades", PREFIX)
give_item( id, "weapon_hegrenade" )
give_item( id, "weapon_flashbang" )
give_item( id, "weapon_smokegrenade" )

gPontos[id] -= get_pcvar_num( gGrenades )
hasGrenades [id] = true;
}
}

case 3: //case da camuflagem
{
if (hasSilent[id])
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu ja compraste ^4Camuflagem ", PREFIX);
return PLUGIN_HANDLED;
}

if( Pontos < get_pcvar_num( gSilentcost ))
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Nao tens suficientes ^4Pontos ^1para comprar este item! ", PREFIX);
return PLUGIN_HANDLED;
}
else
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu compraste ^4Camuflagem", PREFIX);
cmd_camouflage(id)
gPontos[id] -= get_pcvar_num( gSilentcost )

}
}

case 4:
{
if (hasHealth[id])
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu ja compraste ^4Health ", PREFIX);
return PLUGIN_HANDLED;
}

if( Pontos < get_pcvar_num( gHealthcost ))
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Nao tens suficientes ^4Pontos ^1para comprar este item! ", PREFIX);
return PLUGIN_HANDLED;
}
else
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu compraste ^4%d Health", PREFIX, get_pcvar_num( pHealth ))
set_user_health( id, get_user_health( id ) + get_pcvar_num( pHealth ));

gPontos[id] -= get_pcvar_num( gHealthcost )
hasHealth [id] = true;
}
}

case 5:
{
if (hasArmor[id])
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu ja compraste ^4Armor ", PREFIX);
return PLUGIN_HANDLED;
}

if( Pontos < get_pcvar_num( gArmorcost ))
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Nao tens suficientes ^4Pontos ^1para comprar este item! ", PREFIX);
return PLUGIN_HANDLED;
}
else
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu compraste ^4%d Armor", PREFIX, get_pcvar_num( pArmor ))
set_user_armor( id, get_user_armor( id ) + get_pcvar_num( pArmor ) );

gPontos[id] -= get_pcvar_num( gArmorcost )
hasArmor [id] = true;
}
}

case 6:
{
if (hasGravity[id])
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu ja compraste ^4Gravity ", PREFIX);
return PLUGIN_HANDLED;
}

if( Pontos < get_pcvar_num( gGravitycost ))
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Nao tens suficientes ^4Pontos ^1para comprar este item! ", PREFIX);
return PLUGIN_HANDLED;
}
else
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu compraste ^4Gravity", PREFIX)
set_user_gravity( id, get_pcvar_float( gGravity ) );

gPontos[id] -= get_pcvar_num( gGravitycost )
hasGravity [id] = true;
}
}

case 7:
{
if (hasSpeed[id])
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu ja compraste ^4Faster Speed ", PREFIX);
return PLUGIN_HANDLED;
}

if( Pontos < get_pcvar_num( gSpeedcost ))
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Nao tens suficientes ^4Pontos ^1para comprar este item! ", PREFIX);
return PLUGIN_HANDLED;
}
else
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu compraste ^4Faster Speed", PREFIX)
set_user_maxspeed( id, get_pcvar_float( pSpeed ) );

gPontos[id] -= get_pcvar_num( gSpeedcost )
hasSpeed [id] = true;
}
}

case 8:
{
if (hasInvisible[id])
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu ja compraste ^4Invisible ", PREFIX);
return PLUGIN_HANDLED;
}

if( Pontos < get_pcvar_num( gInvisiblecost ))
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Nao tens suficientes ^4Pontos ^1para comprar este item! ", PREFIX);
return PLUGIN_HANDLED;
}
else
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu compraste ^4Invisibility", PREFIX)
set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 0 );

gPontos[id] -= get_pcvar_num( gInvisiblecost )
hasInvisible [id] = true;
}
}

case 9:
{
if (bhopOn[id])
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu ja compraste ^4Este item ", PREFIX);
return PLUGIN_HANDLED;
}

if( Pontos < get_pcvar_num( gBhopcost ))
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Nao tens suficientes ^4Pontos ^1para comprar este item! ", PREFIX);
return PLUGIN_HANDLED;
}
else
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu compraste ^4 [ 12500$ ]", PREFIX)

gPontos[id] -= get_pcvar_num( gBhopcost )
cs_set_user_money(id, cs_get_user_money(id) + 12500);
}
}

case 10:
{
if (hasGlow[id])
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu ja compraste ^4Random Glow ", PREFIX);
return PLUGIN_HANDLED;
}

if( Pontos < get_pcvar_num( gGlowcost ))
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Nao tens suficientes ^4Pontos ^1para comprar este item! ", PREFIX);
return PLUGIN_HANDLED;
}
else
{
ColorChat(id,GREEN, "^1[^4%s^1]^1 Tu compraste ^4Random Glow", PREFIX)
set_user_rendering( id, kRenderFxGlowShell, random( 256 ), random( 256 ), random( 256 ), kRenderNormal, random( 256 ) );

gPontos[id] -= get_pcvar_num( gGlowcost )
hasGlow [id] = true;
}
}
}
return PLUGIN_HANDLED;
}

//CRASH
public client_command(Client)
{
static Cmd[6], Said[100];
read_args(Said,99);
remove_quotes(Said);
read_argv(0,Cmd,5);
if(equali(Cmd,"Say_team",3)&&containi(Said,"% ")!=-1){
return 1;
}
if(equali(Cmd,"Say_team",3)&&containi(Said,"# ")!=-1)
{
return 1;
}
if(equali(Cmd,"Say",3)&&containi(Said,"%")!=-1){
return 1;
}
if(equali(Cmd,"Say",3)&&containi(Said,"#")!=-1)
{
return 1;
}
return PLUGIN_CONTINUE;
}

/* ---| RESETSCORE |--- */
public reset_score(id)
{
cs_set_user_deaths(id, 0)
set_user_frags(id, 0)
cs_set_user_deaths(id, 0)
set_user_frags(id, 0)
ColorChat(id,GREEN, "^1[^4%s^1]^1 O teu score voltou ao 0 ", PREFIX);

return PLUGIN_HANDLED
}
/* ---| JAIL |--- */
public open_jail_cmd(id,level,cid) {
if(!cmd_access(id,level,cid,0))
return PLUGIN_HANDLED

new map[32]
get_mapname(map,31)

if(!get_pcvar_num(cvar_on)) {
return PLUGIN_HANDLED
}

else if(!equali(map,"surf",4)) {
return PLUGIN_HANDLED
}

else {
if(read_argc()>1) {
new arg[8]
read_argv(1,arg,7)
set_task(str_to_float(arg),"open_jail",id)
}
else
open_jail(id)
}
return PLUGIN_HANDLED
}
/* ---| camuflagem |--- */
public cmd_camouflage(id) {

if ( ! get_cvar_num("amxx_camouflage") )
return PLUGIN_HANDLED
new money = cs_get_user_money(id)
new CsTeams:team = cs_get_user_team(id)


if ( !is_user_alive(id) || money < CamoCost ) {
return PLUGIN_HANDLED
}

if ( HasCamo[id] == false ) {

cs_set_user_money( id, cs_get_user_money(id) - CamoCost )
HasCamo[id] = true

if (team == CS_TEAM_CT) {
cs_set_user_model(id, TModels)
return PLUGIN_CONTINUE;
}

else if (team == CS_TEAM_T) {
cs_set_user_model(id, CTModels)
return PLUGIN_CONTINUE
}
}
return PLUGIN_HANDLED
}
/* ---| Show Players Pontos Menu |--- */

public ShowPoints(id){
static opcion[64]

formatex(opcion, charsmax(opcion),"Pontos dos jogadores :")
new iMenu = menu_create(opcion, "HandlePontos")

new players[32], pnum, tempid
new szName[32], szTempid[10]

get_players(players, pnum, "ch")

for( new i; i<pnum; i++ )
{

tempid = players[i]

get_user_name(tempid, szName, 31)
num_to_str(tempid, szTempid, 9)

formatex(opcion,127,"%s - \y[\r%i Pontos\y]",szName, gPontos[tempid]);
menu_additem(iMenu, opcion, szTempid, 0)
}

menu_display(id, iMenu)
return PLUGIN_HANDLED
}

/* ---| Show Players Pontos Handler |--- */

public HandlePontos(id, menu, item)
{
if(item == MENU_EXIT)
{
return PLUGIN_HANDLED
}

new data[6], name[64]
new access, callback

menu_item_getinfo (menu, item, access, data, 5, name, 63, callback)
new tempid = str_to_num (data)

new szName[33], szPlayerName[33]

get_user_name(id, szName, 32)
get_user_name(tempid, szPlayerName, 32)

ColorChat(id, RED, "^1[^4%s^1] User ^4%s ^1Have ^4%i ^1Pontos!",PREFIX ,szPlayerName, gPontos[tempid])

ShowPoints(id);

return PLUGIN_CONTINUE
}

/* ---| Donate Pontos Menu |--- */

public Donate_Menu(id)
{
new iMenu = menu_create("Doar", "handleDonate");

new iPlayers[32], szName[32], szKey[3], iNum, iPlayer;
get_players(iPlayers, iNum,"ch");

for( new i; i < iNum; i++ )
{
iPlayer = iPlayers[i];

num_to_str(iPlayer, szKey, charsmax(szKey));
get_user_name(iPlayer, szName, charsmax(szName));

menu_additem(iMenu, szName, szKey);
}

menu_setprop(iMenu, MPROP_EXITNAME, "Back");
menu_display(id, iMenu, 0);
return 0;
}

/* ---| Donate Pontos Handler |--- */

public handleDonate(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}

new szData[6], iAccess, iCallback;
menu_item_getinfo(menu, item, iAccess, szData, charsmax(szData), _, _, iCallback);

g_iTarget[id] = str_to_num(szData);
new szName[32];
get_user_name(g_iTarget[id], szName, charsmax(szName));

client_cmd(id, "messagemode donate");
return PLUGIN_HANDLED;
}

/* ---| Cmd Donate Pontos |--- */

public CmdDonate(id)
{
new szArg[5];
read_argv(1, szArg, charsmax(szArg));


new iValue = str_to_num(szArg);

if( iValue > gPontos[id] )
{
ColorChat(id,GREEN, "^1[^4%s^1] You only have ^4%i ^1Pontos", PREFIX , gPontos[id]);
return PLUGIN_HANDLED;
}

new iTarget = g_iTarget[id];

if( !iTarget )
{
return PLUGIN_HANDLED;
}

if( iTarget == id )
{
return PLUGIN_HANDLED;
}

gPontos[id] -= iValue;

gPontos[iTarget] += iValue;

new szName[2][32];
get_user_name(iTarget, szName[0], charsmax(szName[]));
get_user_name(id, szName[1], charsmax(szName[]));

ColorChat(id,GREEN, "^1[^4%s^1] Tu doaste ^4%i^1 Pontos a ^4%s !", PREFIX , iValue, szName[0]);
ColorChat(iTarget,GREEN, "^1[^4%s^1] ---^4%s^1--- Deram para ti ^4%i Pontos", PREFIX, szName[1], iValue);


return PLUGIN_HANDLED;
}

/* ---| When Round Start |--- */

public logevent_round_start()
{
if( get_pcvar_num( gPontosystem ) == 1 )
{
new iPlayers[ 32 ], iNum, i, id;
get_players( iPlayers, iNum, "c" );

for( i = 0; i < iNum; i++ )
{
id = iPlayers[ i ];

bhopOn[ id ] = false;
hasGrenades [ id ] = false;
hasSilent [ id ] = false;
hasHealth [ id ] = false;
hasArmor [ id ] = false;
hasGravity [ id ] = false;
hasSpeed [ id ] = false;
hasInvisible [ id ] = false;
hasBhop [ id ] = false;
hasGlow [ id ] = false;

set_user_gravity( id, 1.0 );
set_user_maxspeed( id, 0.0 );
set_user_rendering( id );
set_user_footsteps( id, 0 );
}
}
}

/* ---| When Player Died |--- */

public Hook_Deathmessage()
{
if( get_pcvar_num( gPontosystem ) == 1 )
{
new killer = read_data( 1 );
new victim = read_data( 2 );

if( killer == victim )
{
return PLUGIN_HANDLED;
}

gPontos[ killer ] += get_pcvar_num( gPontosbonus );

bhopOn[ victim ] = false;
hasGrenades [ victim ] = false;
hasSilent [ victim ] = false;
hasHealth [ victim ] = false;
hasArmor [ victim ] = false;
hasGravity [ victim ] = false;
hasSpeed [ victim ] = false;
hasInvisible [ victim ] = false;
hasBhop [ victim ] = false;
hasGlow [ victim ] = false;

set_user_gravity( victim, 1.0 );
set_user_maxspeed( victim, 0.0 );
set_user_rendering( victim );
set_user_footsteps( victim, 0 );

}

return PLUGIN_CONTINUE;
}

/* ---| Cmd For Show Your Pontos |--- */

public cmd_showPontos(id)
{
set_hudmessage(0, 255, 255, 0.0, 0.87, 0, 6.0, 12.0)
show_hudmessage(id, "[ LOJA ] %d Pontos", gPontos [id] )

client_print( id, print_chat, "[ LOJA ] %d Pontos", gPontos[ id ] );
}

/* ---| Cmd For Set Pontos |--- */

public cmd_set(id,level,cid)
{
if(!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED

else
{
new target[32], pid
read_argv(1,target,31)
pid = cmd_target(id,target,2)

new amountstr[10], amount
read_argv(2,amountstr,9)
amount = str_to_num(amountstr)

new name[32], tname[32]
get_user_name(id,name,31)
get_user_name(pid,tname,31)

gPontos[pid] += amount
}
return PLUGIN_HANDLED
}

/* ---| Cmd For Reset Pontos |--- */

public cmd_reset(id,level,cid)
{
if(!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED

else
{
new target[32], pid
read_argv(1,target,31)
pid = cmd_target(id,target,2)

new amountstr[10], amount
read_argv(2,amountstr,9)
amount = str_to_num(amountstr)

new name[32], tname[32]
get_user_name(id,name,31)
get_user_name(pid,tname,31)

if((gPontos[pid] -= amount) < 0)

amount = gPontos[pid]

gPontos[pid] -= amount
client_print(id, print_chat, "[%s] Removeste %d Pontos de %s", PREFIX, amount, tname)
client_print(pid, print_chat, "[%s] %s Foram removidos %d Pontos. [ LOJA ] %d Pontos", PREFIX, name, amount)
}
return PLUGIN_HANDLED
}
/* ---| Client Prethink |--- */
public client_PreThink(id)
{

if( !bhopOn[id] )
return PLUGIN_HANDLED;

entity_set_float(id, EV_FL_fuser2, 0.0)

if (entity_get_int(id, EV_INT_button) & 2)
{
new flags = entity_get_int(id, EV_INT_flags)

if (flags & FL_WATERJUMP)
return PLUGIN_CONTINUE
if ( entity_get_int(id, EV_INT_waterlevel) >= 2 )
return PLUGIN_CONTINUE
if ( !(flags & FL_ONGROUND) )
return PLUGIN_CONTINUE

new Float:velocity[3]
entity_get_vector(id, EV_VEC_velocity, velocity)
velocity[0] *= 1.10
velocity[1] *= 1.10
velocity[2] += 250.0
entity_set_vector(id, EV_VEC_velocity, velocity)

entity_set_int(id, EV_INT_gaitsequence, 9)
}
return PLUGIN_CONTINUE
}

/* ---| Save Players Pontos |--- */

stock save_Pontos( index )
{
gVault = nvault_open( "Pontos_SAVE" );

get_user_authid( index, gSteamID, charsmax( gSteamID ) );

formatex( vKey, charsmax( vKey ), "%sPontos", gSteamID );
formatex( vData, charsmax( vData ), "%d", gPontos[ index ] );
nvault_set( gVault, vKey, vData );
nvault_close( gVault );
}

/* ---| load Players Pontos |--- */

stock load_Pontos( index )
{
gVault = nvault_open( "Pontos_SAVE" );

get_user_authid( index, gSteamID, charsmax( gSteamID ) );

formatex( vKey, charsmax( vKey ), "%sPontos", gSteamID );
gPontos[ index ] = nvault_get( gVault, vKey );
nvault_close( gVault );
}
/* ---| jail |--- */
public open_jail(id) {
new ent,target[32],ent2

for(new i=0;i < sizeof entlist;i++) {
ent=0
ent2=0
while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", entlist[i]))) {
if(pev_valid(ent)) {
//dllfunc(DLLFunc_Touch,ent,id)
pev(ent,pev_target,target,31)
while((ent2 = engfunc(EngFunc_FindEntityByString, ent2, "targetname", target))) {
dllfunc(DLLFunc_Use,ent2,id)
return PLUGIN_HANDLED
}
}
}
}
return PLUGIN_HANDLED
}
/* ---| camuflagem |--- */
public DeathEvent() {

if ( ! get_cvar_num("amxx_camouflage") )
return PLUGIN_HANDLED

new id = read_data(2)

if ( HasCamo[id] == true ) {
set_task( 1.0, "reset_model", id )
}
return PLUGIN_HANDLED
}

public ResetHud(id) {

if ( ! get_cvar_num("amxx_camouflage") )
return PLUGIN_HANDLED

new CsTeams:team = cs_get_user_team(id)

if ( HasCamo[id] == true ) {

if (team == CS_TEAM_CT) {
cs_set_user_model(id, TModels)
}

else if (team == CS_TEAM_T) {
cs_set_user_model(id, CTModels)
}
}
return PLUGIN_HANDLED
}

public reset_model(id) {
cs_reset_user_model(id)
HasCamo[id] = false
}


//hud
public ham_PlayerKilled(victim, attacker)
{
static selfkill;
selfkill = (victim == attacker || !is_user_connected(attacker)) ? true : false;
if (!selfkill)
{
gPontos[attacker]++;
}
}

// After player spawns
public ham_PlayerSpawned_Post(id)
{
if (is_user_connected(id) && is_user_alive(id))
{
set_task(1.0, "ShowHud", id, _, _, "b");
}
}

// Resethud Event
public event_ResetHud(id)
{
ShowHud(id);
}
public ShowHud(id)
{
if (is_user_connected(id) && is_user_alive(id) && (get_user_team(id) == 1 || get_user_team(id) == 2))
{
set_hudmessage(60, 60, 60, 0.01, 0.23, 0, 0.5, 15.0, 2.0, 2.0, -1);
ShowSyncHudMsg(id, g_HudSterVVVXXXxyz, "PONTOS: %d", gPontos[id]);
}
else
{
new idSpec;
new iPlayerName[32];
idSpec = pev(id, PEV_SPEC_TARGET);
get_user_name(idSpec, iPlayerName, 31);
set_hudmessage(60, 60, 60, 0.01, 0.22, 0, 0.5, 15.0, 2.0, 2.0, -1);
ShowSyncHudMsg(id, g_HudSterVVVXXXxyz, "*SPEC* PONTOS: %d", iPlayerName, gPontos[idSpec]);
}

}
//CRASH
public client_putinserver(id)
{
if (is_user_connected(id))
{
new szName[32];
get_user_name(id, szName, 31);
for(new i = 0; i < sizeof(gBlockcmd); i++) {
if(containi(szName, gBlockcmd[i]) != -1) {
server_cmd("kick #%d ^"Cheat Detected^"", get_user_userid(id));
return 1;
}
}

}
return 0;
}

public client_infochanged(id)
{
static const name[] = "name";
static szNewName[32], szOldName[32];
get_user_info(id, name, szNewName, 31 );
get_user_name(id, szOldName, 31 );

for(new i = 0; i < sizeof(gBlockcmd); i++){
if(containi(szNewName, gBlockcmd[i]) != -1)
{
replace_all( szNewName, 32, gBlockcmd[i], "" );
set_user_info(id, name, szNewName );
}
}
}

Last edited by sneaK; 02-28-2019 at 02:22. Reason: Restore to previous version.
MITAR is offline
Reply


Thread Tools
Display Modes

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 10:13.


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