Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <engine>
- #include <cstrike>
- #include <fakemeta_util>
- #include <hamsandwich>
- #include <sqlx>
- enum Color
- {
- NORMAL = 1, // Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
- GREEN, // Culoare Verde.
- TEAM_COLOR, // Culoare Rosu, Albastru, Gri.
- GREY, // Culoarea Gri.
- RED, // Culoarea Rosu.
- BLUE, // Culoarea Albastru.
- };
- new TeamName[ ][ ] =
- {
- "",
- "TERRORIST",
- "CT",
- "SPECTATOR"
- };
- #define SCOREATTRIB_NONE 0
- #define SCOREATTRIB_DEAD ( 1 << 0 )
- #define SCOREATTRIB_BOMB ( 1 << 1 )
- #define SCOREATTRIB_VIP ( 1 << 2 )
- #define Host "localhost"
- #define User "root"
- #define Pass ""
- #define Db "MariaDB"
- new Handle:g_SqlTuple;
- new g_Error[512];
- new bool: is_user_vip[33];
- new const szTag [] = "[VIP]";
- new jumpnum[33] = 0;
- new bool:dojump[33] = false;
- new const g_szBeginning[ ] = "Membrii VIP"
- new g_szMessage[ 256 ];
- new SyncHudMessage;
- new Round[33];
- new cvar_vip_maxap, cvar_vip_maxhp, cvar_vip_showC, cvar_vip_showH, cvar_vip_in_out, cvar_start_hp, cvar_start_ap, cvar_start_money, cvar_vip_jump, cvar_hp_kill, cvar_ap_kill;
- public plugin_init()
- {
- register_plugin("VIP Sql","1.0","Truth");
- register_clcmd("say /vip", "vip_info");
- register_clcmd("say", "handle_say");
- register_clcmd("say_team", "handle_say");
- RegisterHam(Ham_Spawn, "player", "Spawn", true);
- register_event("DeathMsg", "eDeathMsg", "a");
- set_task( 1.0, "TaskDisplayVips", _, _, _, "b", 0 );
- register_message(get_user_msgid( "ScoreAttrib" ), "MessageScoreAttrib");
- SyncHudMessage = CreateHudSyncObj( );
- cvar_start_hp = register_cvar("amx_start_hp", "150");
- cvar_start_ap = register_cvar("amx_start_ap", "180");
- cvar_start_money = register_cvar("amx_start_money", "8000");
- cvar_vip_jump = register_cvar("amx_vip_jump", "1" );
- cvar_hp_kill = register_cvar("amx_vip_addhp", "10");
- cvar_ap_kill = register_cvar("amx_vip_addap", "10");
- cvar_vip_in_out = register_cvar("amx_vip_in_out", "1");
- cvar_vip_showC = register_cvar("amx_vip_show_chat", "1");
- cvar_vip_showH = register_cvar("amx_vip_show_hud", "1");
- cvar_vip_maxhp = register_cvar("amx_vip_maxhp", "180");
- cvar_vip_maxap = register_cvar("amx_vip_maxap", "200");
- set_task(120.0, "mesaj_info", _, _, _, "b");
- // -- || MySql Config || -- //
- g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db);
- new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511);
- if(SqlConnection == Empty_Handle)
- set_fail_state(g_Error);
- new Handle:Queries;
- Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS test (name VARCHAR(100),data DATE)");
- if(!SQL_Execute(Queries))
- {
- SQL_QueryError(Queries,g_Error,511);
- set_fail_state(g_Error);
- }
- SQL_FreeHandle(Queries);
- SQL_FreeHandle(SqlConnection);
- // -- || End MySql Config || -- //
- }
- public client_connect(id) Load(id);
- public vip_info(id) show_motd(id, "/addons/amxmodx/configs/vip_info.html");
- public mesaj_info() ColorChat(0, GREEN, "^4%s ^1Tastati in chat ^4/vip ^1pentru a vedea beneficiile si pretul vip-ului.", szTag);
- public client_putinserver(id)
- {
- set_task(2.0, "in", id);
- if(is_user_vip[id])
- {
- jumpnum[id] = 0
- dojump[id] = false
- Round[id] = 0;
- }
- }
- public client_disconnected(id)
- {
- set_task(2.0, "out", id);
- if(is_user_vip[id])
- {
- jumpnum[id] = 0;
- dojump[id] = false;
- Round[id] = 0;
- }
- }
- public in(id)
- {
- if(get_pcvar_num(cvar_vip_in_out))
- {
- if(is_user_vip[id]) {
- new name[33];
- get_user_name(id, name, sizeof(name) - 1);
- ColorChat(0, GREEN, "^4%s ^1VIP: ^4%s ^1s-a conectat.", szTag, name);
- }
- }
- return 1;
- }
- public out(id)
- {
- if(get_pcvar_num(cvar_vip_in_out))
- {
- if(is_user_vip[id]) {
- new name[33];
- get_user_name(id, name, sizeof(name) - 1);
- ColorChat(0, GREEN, "^4%s ^1VIP: ^4%s ^1s-a deconectat.", szTag, name);
- }
- }
- return 1;
- }
- public Spawn(id) {
- if(is_user_vip[id]) {
- Round[id]++;
- if(Round[id]>=6) VipMenu(id);
- }
- new MapName[32]; get_mapname(MapName, sizeof(MapName));
- if(equali(MapName, "35hp") || equali(MapName, "35hp_2") || equali(MapName, "31hp") || equali(MapName, "1hp") || equali(MapName, "100hp") ) {
- is_user_vip[id]=false;
- }
- if(is_user_vip[id] && is_user_alive(id))
- {
- switch(get_user_team(id))
- {
- case 1:
- {
- fm_set_user_health(id, get_pcvar_num(cvar_start_hp));
- fm_set_user_armor(id, get_pcvar_num(cvar_start_ap));
- cs_set_user_money(id, cs_get_user_money(id) + get_pcvar_num(cvar_start_money));
- }
- case 2:
- {
- fm_set_user_health(id, get_pcvar_num( cvar_start_hp ));
- fm_set_user_armor(id, get_pcvar_num( cvar_start_ap ));
- cs_set_user_money(id, cs_get_user_money(id) + get_pcvar_num(cvar_start_money));
- }
- }
- }
- }
- public VipMenu(id) {
- new ShopMenu = menu_create("\y[\rVIP Classic\y] \wMeniu \yVIP", "give_items");
- switch(get_user_team(id)) {
- case 1: {
- menu_additem(ShopMenu, "Ak47+Deagle+Set grenazi", "1");
- menu_additem(ShopMenu, "Galil+Deagle+Set grenazi", "2");
- }
- case 2:
- {
- menu_additem(ShopMenu, "M4a1+Deagle+Set grenazi", "1");
- menu_additem(ShopMenu, "Famas+Deagle+Set grenazi", "2");
- }
- }
- menu_additem(ShopMenu, "Awp+Deagle+Set grenazi", "3");
- menu_setprop(ShopMenu, MPROP_EXIT, MEXIT_ALL);
- menu_display(id, ShopMenu, 0);
- return 1;
- }
- public give_items(id, ShopMenu, item) {
- if(item == MENU_EXIT) {
- menu_destroy(ShopMenu);
- return 1;
- }
- switch(get_user_team(id)) {
- case 1: {
- switch(item)
- {
- case 0:
- {
- fm_strip_user_weapons(id);
- fm_give_item(id, "weapon_knife");
- fm_give_item(id, "weapon_ak47");
- fm_give_item(id, "weapon_deagle");
- fm_give_item(id, "weapon_hegrenade");
- fm_give_item(id, "weapon_flashbang");
- cs_set_user_bpammo(id, CSW_HEGRENADE, 1);
- cs_set_user_bpammo(id, CSW_FLASHBANG, 2);
- cs_set_user_bpammo(id, CSW_AK47, 90);
- cs_set_user_bpammo(id, CSW_DEAGLE, 35);
- ColorChat(id,GREEN,"^4%s ^1Ai ales ^4Ak47^1+^4Deagle^1+^4Set grenazi^1.", szTag);
- }
- case 1:
- {
- fm_strip_user_weapons(id);
- fm_give_item(id, "weapon_knife");
- fm_give_item(id, "weapon_galil");
- fm_give_item(id, "weapon_deagle");
- fm_give_item(id, "weapon_hegrenade");
- fm_give_item(id, "weapon_flashbang");
- cs_set_user_bpammo(id, CSW_HEGRENADE, 1);
- cs_set_user_bpammo(id, CSW_FLASHBANG, 2);
- cs_set_user_bpammo(id, CSW_GALIL, 90);
- cs_set_user_bpammo(id, CSW_DEAGLE, 35);
- ColorChat(id,GREEN,"^4%s ^1Ai ales ^4Galil^1+^4Deagle^1+^4Set grenazi^1.", szTag);
- }
- case 2:
- {
- fm_strip_user_weapons(id);
- fm_give_item(id, "weapon_knife");
- fm_give_item(id, "weapon_awp");
- fm_give_item(id, "weapon_deagle");
- fm_give_item(id, "weapon_hegrenade");
- fm_give_item(id, "weapon_flashbang");
- cs_set_user_bpammo(id, CSW_HEGRENADE, 1);
- cs_set_user_bpammo(id, CSW_FLASHBANG, 2);
- cs_set_user_bpammo(id, CSW_AWP, 30);
- cs_set_user_bpammo(id, CSW_DEAGLE, 35);
- ColorChat(id,GREEN,"^4%s ^1Ai ales ^4Awp^1+^4Deagle^1+^4Set grenazi^1.", szTag);
- }
- }
- }
- case 2: {
- switch(item)
- {
- case 0:
- {
- fm_strip_user_weapons(id);
- fm_give_item(id, "weapon_knife");
- fm_give_item(id, "weapon_m4a1");
- fm_give_item(id, "weapon_deagle");
- fm_give_item(id, "weapon_hegrenade");
- fm_give_item(id, "weapon_flashbang");
- cs_set_user_bpammo(id, CSW_HEGRENADE, 1);
- cs_set_user_bpammo(id, CSW_FLASHBANG, 2);
- cs_set_user_bpammo(id, CSW_M4A1, 90);
- cs_set_user_bpammo(id, CSW_DEAGLE, 35);
- ColorChat(id,GREEN,"^4%s ^1Ai ales ^4M4A1^1+^4Deagle^1+^4Set grenazi^1.", szTag);
- }
- case 1:
- {
- fm_strip_user_weapons(id);
- fm_give_item(id, "weapon_knife");
- fm_give_item(id, "weapon_famas");
- fm_give_item(id, "weapon_deagle");
- fm_give_item(id, "weapon_hegrenade");
- fm_give_item(id, "weapon_flashbang");
- cs_set_user_bpammo(id, CSW_HEGRENADE, 1);
- cs_set_user_bpammo(id, CSW_FLASHBANG, 2);
- cs_set_user_bpammo(id, CSW_FAMAS, 90);
- cs_set_user_bpammo(id, CSW_DEAGLE, 35);
- ColorChat(id,GREEN,"^4%s ^1Ai ales ^4Famas^1+^4Deagle^1+^4Set grenazi^1.", szTag);
- }
- case 2:
- {
- fm_strip_user_weapons(id);
- fm_give_item(id, "weapon_knife");
- fm_give_item(id, "weapon_awp");
- fm_give_item(id, "weapon_deagle");
- fm_give_item(id, "weapon_hegrenade");
- fm_give_item(id, "weapon_flashbang");
- cs_set_user_bpammo(id, CSW_HEGRENADE, 1);
- cs_set_user_bpammo(id, CSW_FLASHBANG, 2);
- cs_set_user_bpammo(id, CSW_AWP, 30);
- cs_set_user_bpammo(id, CSW_DEAGLE, 35);
- ColorChat(id,GREEN,"^4%s ^1Ai ales ^4Awp^1+^4Deagle^1+^4Set grenazi^1.", szTag);
- }
- }
- }
- }
- menu_destroy(ShopMenu);
- return 1;
- }
- public client_PreThink(id)
- {
- if(!is_user_alive(id)) return PLUGIN_CONTINUE
- if(!is_user_vip[id]) return PLUGIN_CONTINUE
- new nbut = get_user_button(id)
- new obut = get_user_oldbutton(id)
- if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP))
- {
- if(jumpnum[id] < get_pcvar_num(cvar_vip_jump))
- {
- dojump[id] = true
- jumpnum[id]++
- return PLUGIN_CONTINUE
- }
- }
- if((nbut & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
- {
- jumpnum[id] = 0
- return PLUGIN_CONTINUE
- }
- return PLUGIN_CONTINUE
- }
- public client_PostThink(id)
- {
- if(!is_user_alive(id)) return PLUGIN_CONTINUE
- if(!is_user_vip[id]) return PLUGIN_CONTINUE
- if(dojump[id] == true)
- {
- new Float:velocity[3]
- entity_get_vector(id,EV_VEC_velocity,velocity)
- velocity[2] = random_float(265.0,285.0)
- entity_set_vector(id,EV_VEC_velocity,velocity)
- dojump[id] = false
- return PLUGIN_CONTINUE
- }
- return PLUGIN_CONTINUE
- }
- public eDeathMsg()
- {
- new iKiller = read_data( 1 );
- new VIP_MAXHP = get_pcvar_num(cvar_vip_maxhp);
- new VIP_MAX_HP = get_user_health(iKiller);
- new VIP_MAXAP = get_pcvar_num(cvar_vip_maxap);
- new VIP_MAX_AP = get_user_armor(iKiller);
- if(is_user_alive(iKiller))
- {
- if(is_user_vip[iKiller])
- {
- fm_set_user_health(iKiller, get_user_health(iKiller) + get_pcvar_num(cvar_hp_kill));
- fm_set_user_armor(iKiller, get_user_armor(iKiller) + get_pcvar_num(cvar_ap_kill));
- }
- }
- if(VIP_MAX_HP >= VIP_MAXHP)
- {
- fm_set_user_health(iKiller, get_pcvar_num(cvar_vip_maxhp));
- return 1;
- }
- if(VIP_MAX_AP >= VIP_MAXAP)
- {
- fm_set_user_armor(iKiller, get_pcvar_num(cvar_vip_maxap));
- return 1;
- }
- return 1;
- }
- public MessageScoreAttrib(iMsgID, iDest, iReceiver) {
- new iPlayer = get_msg_arg_int(1);
- if(is_user_connected( iPlayer ) && is_user_vip[ iPlayer ]) {
- set_msg_arg_int(2, ARG_BYTE, is_user_alive(iPlayer) ? SCOREATTRIB_VIP : SCOREATTRIB_DEAD);
- }
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // VIP's Online by sDs*Argon |
- //==========================================================================================================
- public print_adminlist(user) {
- if(get_pcvar_num(cvar_vip_showC))
- {
- new adminnames[33][32];
- new message[256];
- new id, count, x, len;
- for(id = 1 ; id <= get_maxplayers() ; id++)
- if(is_user_connected(id))
- if(is_user_vip[id])
- get_user_name(id, adminnames[count++], 31);
- len = format(message, 255, "^x04 VIP ONLINE: ");
- if(count > 0) {
- for(x = 0 ; x < count ; x++) {
- len += format(message[len], 255-len, "%s%s ", adminnames[x], x < (count-1) ? ", ":"");
- if(len > 96) {
- print_message(user, message);
- len = format(message, 255, "^x04 ");
- }
- }
- print_message(user, message);
- }
- else {
- len += format(message[len], 255-len, "No VIP online.");
- print_message(user, message);
- }
- }
- }
- stock print_message(id, msg[]) {
- message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, id);
- write_byte(id);
- write_string(msg);
- message_end();
- }
- public handle_say(id) {
- new said[192];
- read_args(said,192);
- if(contain(said, "/vips") != -1)
- set_task(0.1,"print_adminlist",id);
- return PLUGIN_CONTINUE;
- }
- public TaskDisplayVips( )
- {
- if(get_pcvar_num(cvar_vip_showH)) {
- static iPlayers[ 32 ];
- static iPlayersNum;
- get_players( iPlayers, iPlayersNum, "ch" );
- if( !iPlayersNum )
- return;
- static iVipsConnected, szVipsNames[ 128 ], szName[ 32 ];
- formatex( szVipsNames, sizeof ( szVipsNames ) -1, "" ); // Is this needed ?
- iVipsConnected = 0;
- static id, i;
- for( i = 0; i < iPlayersNum; i++ )
- {
- id = iPlayers[ i ];
- if( is_user_vip[id] )
- {
- get_user_name( id, szName, sizeof ( szName ) -1 );
- add( szVipsNames, sizeof ( szVipsNames ) -1, szName );
- add( szVipsNames, sizeof ( szVipsNames ) -1, "^n" );
- iVipsConnected++;
- }
- }
- formatex( g_szMessage, sizeof ( g_szMessage ) -1, "%s ( %i )^n%s",
- g_szBeginning, iVipsConnected, szVipsNames );
- set_hudmessage( 25, 255, 25, 0.01, 0.25, 0, 0.0, 1.0, 0.1, 0.1, -1 );
- ShowSyncHudMsg( 0, SyncHudMessage, g_szMessage );
- }
- }
- public Load(id)
- {
- new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
- if(SqlConnection == Empty_Handle)
- set_fail_state(g_Error);
- new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT * FROM `test` WHERE `data` >= CURRENT_DATE");
- if( !SQL_Execute(Query) )
- {
- SQL_QueryError(Query,g_Error,511);
- log_amx("[ZM VIP] SQL error: can't load VIPs: '%s'", g_Error);
- set_fail_state(g_Error);
- }
- else if (!SQL_NumResults(Query))
- {
- log_amx("[ZM VIP] Empty table!" )
- }
- else
- {
- new qcolName = SQL_FieldNameToNum(Query, "name");
- new Name[44];
- new szName[33];
- get_user_name(id, szName, 32);
- new num;
- while (SQL_MoreResults(Query))
- {
- Name[0] = EOS;
- SQL_ReadResult(Query, qcolName, Name, sizeof(Name)-1);
- if(equali(Name, szName)) {
- is_user_vip[id] = true;
- }
- else
- {
- is_user_vip[id] = false;
- }
- num++
- SQL_NextRow(Query)
- }
- if( num )log_amx("[ZM VIP] Loaded %d VIPs from database.", num );
- else log_amx("[ZM VIP] VIPs not found!");
- }
- SQL_FreeHandle(Query);
- SQL_FreeHandle(SqlConnection);
- }
- stock ColorChat( id, Color:iType, const msg[ ], { Float, Sql, Result, _}:... )
- {
- // Daca nu se afla nici un jucator pe server oprim TOT. Altfel dam de erori..
- if( !get_playersnum( ) ) return;
- new szMessage[ 256 ];
- switch( iType )
- {
- // Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
- case NORMAL: szMessage[ 0 ] = 0x01;
- // Culoare Verde.
- case GREEN: szMessage[ 0 ] = 0x04;
- // Alb, Rosu, Albastru.
- default: szMessage[ 0 ] = 0x03;
- }
- vformat( szMessage[ 1 ], 251, msg, 4 );
- // Ne asiguram ca mesajul nu este mai lung de 192 de caractere.Altfel pica server-ul.
- szMessage[ 192 ] = '^0';
- new iTeam, iColorChange, iPlayerIndex, MSG_Type;
- if( id )
- {
- MSG_Type = MSG_ONE_UNRELIABLE;
- iPlayerIndex = id;
- }
- else
- {
- iPlayerIndex = CC_FindPlayer( );
- MSG_Type = MSG_ALL;
- }
- iTeam = get_user_team( iPlayerIndex );
- iColorChange = CC_ColorSelection( iPlayerIndex, MSG_Type, iType);
- CC_ShowColorMessage( iPlayerIndex, MSG_Type, szMessage );
- if( iColorChange ) CC_Team_Info( iPlayerIndex, MSG_Type, TeamName[ iTeam ] );
- }
- stock CC_ShowColorMessage( id, const iType, const szMessage[ ] )
- {
- static bool:bSayTextUsed;
- static iMsgSayText;
- if( !bSayTextUsed )
- {
- iMsgSayText = get_user_msgid( "SayText" );
- bSayTextUsed = true;
- }
- message_begin( iType, iMsgSayText, _, id );
- write_byte( id )
- write_string( szMessage );
- message_end( );
- }
- stock CC_Team_Info( id, const iType, const szTeam[ ] )
- {
- static bool:bTeamInfoUsed;
- static iMsgTeamInfo;
- if( !bTeamInfoUsed )
- {
- iMsgTeamInfo = get_user_msgid( "TeamInfo" );
- bTeamInfoUsed = true;
- }
- message_begin( iType, iMsgTeamInfo, _, id );
- write_byte( id );
- write_string( szTeam );
- message_end( );
- return 1;
- }
- stock CC_ColorSelection( id, const iType, Color:iColorType)
- {
- switch( iColorType )
- {
- case RED: return CC_Team_Info( id, iType, TeamName[ 1 ] );
- case BLUE: return CC_Team_Info( id, iType, TeamName[ 2 ] );
- case GREY: return CC_Team_Info( id, iType, TeamName[ 0 ] );
- }
- return 0;
- }
- stock CC_FindPlayer( )
- {
- new iMaxPlayers = get_maxplayers( );
- for( new i = 1; i <= iMaxPlayers; i++ )
- if( is_user_connected( i ) )
- return i;
- return -1;
- }
- public plugin_end()
- SQL_FreeHandle(g_SqlTuple);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement