Code: Select all
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fun>
#include <csx>
#include <colorchat>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
// PUNCTE
new g_Plant = 1;
new g_Defuse = 1;
new g_KillNormal = 1;
new g_HeadShot = 1;
new g_Knife = 1;
new g_KillGrenada = 1;
////////////
// Preturi Grade
new g_pretManager = 25000
new g_pretGod = 23000
new g_pretSMod = 5000
/////////////////
///////////////
#define TAG "[server]"
///////////////
// FLAG
#define flagManager "abcd"
#define flagGod "abc"
#define flagSmod "ab"
///////////////////////////
new Points [ 33 ];
new SaveDataFile [ 128 ];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event ( "DeathMsg", "eDeath", "a" );
register_clcmd( "say /shop","Meniu" );
register_clcmd( "say_team /shop", "Meniu");
new DataDir [ 64 ];
get_configsdir ( DataDir, charsmax ( DataDir ) );
format ( SaveDataFile, 127, "%s/Points.dat", DataDir );
}
public plugin_natives ( )
{
register_native ( "pl_get_user_points", "get_user_points", 1 );
register_native ( "pl_set_user_points", "set_user_points", 1 );
}
public get_user_points ( id )
{
return Points [ id ];
}
public set_user_points ( id, PointsNum )
{
Points [ id ] = PointsNum;
}
public eDeath (id, level, cid)
{
new Killer = read_data (1);
new Victim = read_data (2);
new headshot = read_data (3);
new arma = get_user_weapon(Killer);
if ( Killer == Victim ) return PLUGIN_HANDLED;
if (headshot)
{
Points[Killer] += g_HeadShot;
if(get_user_flags(id) & ADMIN_LEVEL_H)
{
Points[Killer] += g_HeadShot;
}
}
else if(arma == CSW_KNIFE)
{
Points[Killer] += g_Knife;
if(get_user_flags(id) & ADMIN_LEVEL_H)
{
Points[Killer] += g_Knife;
}
}
else if(arma == CSW_HEGRENADE)
{
Points[Killer] += g_KillGrenada;
if(get_user_flags(id) & ADMIN_LEVEL_H)
{
Points[Killer] += g_KillGrenada;
}
}
else
{
Points[Killer] += g_KillNormal;
if(get_user_flags(id) & ADMIN_LEVEL_H)
{
Points[Killer] += g_KillNormal;
}
}
return PLUGIN_CONTINUE;
}
public bomb_planted(planter)
{
Points[planter] += g_Plant;
if(get_user_flags(planter) & ADMIN_LEVEL_H)
{
Points[planter] += g_Plant;
}
}
public bomb_defused(defuser)
{
if(get_user_flags(defuser) & ADMIN_LEVEL_H)
{
Points[defuser] += g_Defuse;
}
Points[defuser] += g_Defuse;
}
public Meniu( id )
{
new menu = menu_create( "\rMeniu Grade:", "menu_handler" );
menu_additem( menu, "\rManager \w- \y%s", "", g_pretManager );
menu_additem( menu, "\rGod \w- \y%s", "", 0, g_pretGod );
menu_additem( menu, "\rSuper-Mod \w- \y%s", "", 0, g_pretSMod);
menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
menu_display( id, menu, 0 );
}
public menu_handler( id, level, menu, item )
{
new ip[32]
get_user_ip(id, ip, 31)
switch( item )
{
case 0:
{
if(Points[id] >= g_pretManager)
{
Points[id] -= g_pretManager;
server_cmd("amx_addadmin ^"%s^" ^"%s^" ^"^" ^"ip^"", ip, flagManager)
ColorChat(id, GREEN, "%s ^01Ai achizitionat grad-ul de ^04Manager", TAG)
}
else if(get_user_flags(id) & ADMIN_RESERVATION)
{
ColorChat(id, GREEN, "%s ^01Ai deja un grad administrativ", TAG)
}
else
{
ColorChat(id, GREEN, "%s ^01Nu ai punctele necesare pentru a achizitiona grad-ul", TAG)
}
}
case 1:
{
if(Points[id] >= g_pretGod )
{
Points[id] -= g_pretGod;
server_cmd("amx_addadmin ^"%s^" ^"%s^" ^"^" ^"ip^"", ip, flagGod)
ColorChat(id, GREEN, "%s ^01Ai achizitionat grad-ul de ^04God", TAG)
}
else if(get_user_flags(id) & ADMIN_RESERVATION)
{
ColorChat(id, GREEN, "%s ^01Ai deja un grad administrativ", TAG)
}
else
{
ColorChat(id, GREEN, "%s ^01Nu ai punctele necesare pentru a achizitiona grad-ul", TAG)
}
}
case 2:
{
if(Points[id] >= g_pretSMod)
{
Points[id] -= g_pretSMod;
server_cmd("amx_addadmin ^"%s^" ^"%s^" ^"^" ^"ip^"", ip, flagSmod)
ColorChat(id, GREEN, "%s ^01Ai achizitionat grad-ul de ^04Super-Moderator", TAG)
}
else if(get_user_flags(id) & ADMIN_RESERVATION)
{
ColorChat(id, GREEN, "%s ^01Ai deja un grad administrativ", TAG)
}
else
{
ColorChat(id, GREEN, "%s ^01Nu ai punctele necesare pentru a achizitiona grad-ul", TAG)
}
}
}
menu_destroy( menu );
return PLUGIN_HANDLED;
}
public client_connect ( id )
{
LoadPoints ( id );
}
public client_disconnect ( id )
{
SavePoints ( id );
}
public LoadPoints ( id )
{
new ip [ 32 ];
get_user_ip ( id, ip, 31 );
new Line [ 128 ], IsPlayer = false, Arg1 [ 32 ], Arg2 [ 32 ];
new File = fopen ( SaveDataFile, "rt" )
while ( !feof ( File ) ) {
fgets ( File, Line, 127 );
trim ( Line );
parse ( Line, Arg1, 31, Arg2, 31 );
if ( equali ( Arg1, ip ) ) {
Points [ id ] = str_to_num ( Arg2 );
IsPlayer = true;
break;
}
}
fclose ( File );
if ( !IsPlayer )
Points [ id ] = 0;
}
public SavePoints ( id )
{
new ip[32];
get_user_ip(id, ip, 31)
new nume[32]
get_user_name(id, nume, 31)
new Save [ 1024 ];
format ( Save, sizeof ( Save ) -1, "^"%s^" Puncte: %d Nume: %s", ip, Points [id], nume );
new Line [ 128 ], Linie, IsPlayer = false, Arg1 [ 32 ]
new File = fopen ( SaveDataFile, "rt" );
while ( !feof ( File ) ) {
fgets ( File, Line, 127 );
parse ( Line, Arg1, 31 );
if ( equali ( Arg1, ip ) ) {
write_file ( SaveDataFile, Save, Linie );
IsPlayer = true;
break;
}
Linie++
}
fclose ( File );
if ( !IsPlayer )
write_file ( SaveDataFile, Save, -1 );
}
si punctele se salveaza in configs/Points.dat cu urmatorul format -> IP Puncte: nr.pct Nume: ultimul nume pe care l-a folosit