Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <engine>
- #include <fakemeta>
- #include <fun>
- #include <cstrike>
- #include <hamsandwich>
- #define PLUGIN "Beneficii"
- #define VERSION "1.0"
- enum eData {
- Name[32],
- Flags,
- SpawnHP,
- SpawnAP,
- MoneyKill,
- HpKill,
- ApKill,
- Jumps
- }
- new g_iJumpsNum[33], g_iMaxJumps[33];
- new bool:g_bIsJumping[33];
- new bool:g_bHaveBenefits[33];
- new g_iBenefitsNum = 0;
- new Array:g_aBenefits;
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, "iF .!." );
- g_aBenefits = ArrayCreate(eData);
- RegisterHam(Ham_Spawn, "player", "HamPlayerSpawn", 1);
- RegisterHam(Ham_Player_Jump, "player", "hamPlayerJump", 0)
- register_event("DeathMsg", "evDeathMsg", "a");
- register_clcmd("say /vips", "cmdShowBenefits");
- register_clcmd("say /beneficii", "cmdShowRankBenefits");
- }
- /* Plugin cfg */
- public plugin_cfg()
- {
- new szLineData[128], szName[32], szFlags[32], szSpawnHP[8], szSpawnAP[8], szMoneyPerKill[8], szHpPerKill[8], szApPerKill[8], szJumpsNum[8];
- new aData[eData]
- new szConfigsDir[128];
- get_configsdir(szConfigsDir, charsmax(szConfigsDir));
- add(szConfigsDir, charsmax(szConfigsDir), "/benefits.ini");
- if(!file_exists(szConfigsDir))
- {
- write_file(szConfigsDir, ";Numele flagului Flagul HP Spawn AP Spawn Money per kill HP per Kill Armor per Kill Numar sarituri (1 = No multijump)");
- write_file(szConfigsDir, ";Exemplu:");
- write_file(szConfigsDir, ";^"VIP Diamond^" ^"bcdefghijkt^" ^"125^" ^"150^" ^"2000^" ^"25^" ^"50^" ^"2^"");
- }
- new f = fopen(szConfigsDir, "rt");
- if(!f)
- return;
- while(!feof(f))
- {
- fgets(f, szLineData, charsmax(szLineData));
- if(szLineData[0] == ';' || !szLineData[0])
- continue;
- parse(szLineData, szName, charsmax(szName), szFlags, charsmax(szFlags), szSpawnHP, charsmax(szSpawnHP), szSpawnAP, charsmax(szSpawnAP), szMoneyPerKill, charsmax(szMoneyPerKill), szHpPerKill, charsmax(szHpPerKill), szApPerKill, charsmax(szApPerKill), szJumpsNum, charsmax(szJumpsNum));
- copy(aData[Name], charsmax(aData[Name]), szName);
- aData[Flags] = read_flags(szFlags);
- aData[SpawnHP] = str_to_num(szSpawnHP);
- aData[SpawnAP] = str_to_num(szSpawnAP);
- aData[MoneyKill] = str_to_num(szMoneyPerKill);
- aData[HpKill] = str_to_num(szHpPerKill);
- aData[ApKill] = str_to_num(szApPerKill);
- if(!str_to_num(szJumpsNum))
- aData[Jumps] = 1;
- else
- aData[Jumps] = str_to_num(szJumpsNum);
- ArrayPushArray(g_aBenefits, aData);
- g_iBenefitsNum++;
- }
- }
- /* When client join to server */
- public client_putinserver(id)
- {
- new aData[eData];
- g_bHaveBenefits[id] = false;
- g_bIsJumping[id] = false;
- g_iJumpsNum[id] = 0;
- g_iMaxJumps[id] = 1;
- for (new i; i < g_iBenefitsNum; i++)
- {
- ArrayGetArray(g_aBenefits, i, aData)
- if(get_user_flags(id) == aData[Flags])
- {
- g_bHaveBenefits[id] = true;
- g_iMaxJumps[id] = aData[Jumps];
- break;
- }
- }
- }
- /* Player Spawn ( Hamsandwich ) */
- public HamPlayerSpawn(id)
- {
- if(!is_user_alive(id) || !g_bHaveBenefits[id])
- return;
- new aData[eData];
- for (new i; i < g_iBenefitsNum; i++)
- {
- ArrayGetArray(g_aBenefits, i, aData);
- if(get_user_flags(id) == aData[Flags])
- {
- if(aData[SpawnHP] > 0)
- set_user_health(id, aData[SpawnHP]);
- if(aData[SpawnAP] > 0)
- set_user_armor(id, aData[SpawnAP]);
- break;
- }
- }
- }
- /* Event Death */
- public evDeathMsg( )
- {
- new iKiller = read_data(1);
- new iVictim = read_data(2);
- if(iKiller == iVictim || !is_user_alive(iKiller) || !g_bHaveBenefits[iKiller])
- return;
- new aData[eData];
- for (new i; i < g_iBenefitsNum; i++)
- {
- ArrayGetArray(g_aBenefits, i, aData);
- if(get_user_flags(iKiller) == aData[Flags])
- {
- cs_set_user_money(iKiller, cs_get_user_money(iKiller) + aData[MoneyKill]);
- set_user_health(iKiller, get_user_health(iKiller) + aData[HpKill]);
- set_user_armor(iKiller, get_user_armor(iKiller) + aData[ApKill]);
- break;
- }
- }
- }
- /* Multijump - H.RED.ZONE Code */
- public hamPlayerJump(id)
- {
- if(!is_user_alive(id))
- {
- return HAM_HANDLED;
- }
- if( pev( id, pev_flags ) & FL_WATERJUMP || pev(id, pev_waterlevel) >= 2 || !(get_pdata_int(id, 246) & IN_JUMP) )
- {
- return HAM_IGNORED
- }
- if(pev( id, pev_flags ) & FL_ONGROUND)
- {
- g_iJumpsNum[ id ] = 0;
- return HAM_IGNORED
- }
- if( get_pdata_float(id, 251) < 500 && ++g_iJumpsNum[id] < g_iMaxJumps[id] )
- {
- new Float:fVelocity[ 3 ];
- pev( id, pev_velocity, fVelocity );
- fVelocity[ 2 ] = 268.328157;
- set_pev( id, pev_velocity, fVelocity );
- return HAM_HANDLED
- }
- return HAM_IGNORED
- }
- /* Show Benefits Ranks */
- public cmdShowRankBenefits(id)
- {
- new menu, szText[40], aData[eData];
- menu = menu_create("\w[ \yFurien Benefits \w] \rVIP's Ranks", "benefitsMenuHandler");
- for (new i; i < g_iBenefitsNum; i++)
- {
- ArrayGetArray(g_aBenefits, i, aData);
- formatex(szText, charsmax(szText), "\y%s %s", aData[Name], get_user_flags(id) == aData[Flags] ? "\r*" : "");
- menu_additem(menu, szText);
- }
- menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
- menu_display(id, menu, 0);
- }
- public benefitsMenuHandler(id, menu, item)
- {
- if(item == MENU_EXIT)
- {
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- showDetailsMenu(id, item);
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- /* Show Benefits Ranks Details */
- public showDetailsMenu(id, item)
- {
- new menu, szText[64], aData[eData];
- ArrayGetArray(g_aBenefits, item, aData);
- formatex(szText, charsmax(szText), "\w[ \yFurien Benefits \w] \r%s", aData[Name]);
- menu = menu_create(szText, "detailsMenuHandler");
- formatex(szText, charsmax(szText), "\yHP Spawn: \r%d", aData[SpawnHP]);
- menu_additem(menu, szText);
- formatex(szText, charsmax(szText), "\yAP Spawn: \r%d", aData[SpawnAP]);
- menu_additem(menu, szText);
- formatex(szText, charsmax(szText), "\yMoney per kill: \r%d \r$", aData[MoneyKill]);
- menu_additem(menu, szText);
- formatex(szText, charsmax(szText), "\yHP per kill: \r%d", aData[HpKill]);
- menu_additem(menu, szText);
- formatex(szText, charsmax(szText), "\yAP per kill: \r%d", aData[ApKill]);
- menu_additem(menu, szText);
- if(aData[Jumps] > 1)
- formatex(szText, charsmax(szText), "\yMultijump: \rx%d", aData[Jumps]);
- else
- formatex(szText, charsmax(szText), "\yMultijump: \dNO");
- menu_additem(menu, szText);
- menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
- menu_display(id, menu, 0);
- }
- public detailsMenuHandler(id, menu, item)
- {
- if(item == MENU_EXIT)
- {
- cmdShowRankBenefits(id)
- return PLUGIN_HANDLED;
- }
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- /* Show users with benefits */
- public cmdShowBenefits(id)
- {
- new iPlayers[32], iNum, szMessage[128], contor;
- get_players(iPlayers, iNum);
- formatex(szMessage, charsmax(szMessage), "!nBenefits ON: ");
- for(new i;i<iNum;i++)
- {
- new x = iPlayers[i];
- if(g_bHaveBenefits[x])
- {
- new szName[32], szMsg[128];
- get_user_name(x, szName, charsmax(szName));
- formatex(szMsg, charsmax(szMsg), "!g%s!n,", szName);
- add(szMessage, charsmax(szMessage), szMsg);
- contor++;
- }
- }
- if(contor)
- {
- szMessage[strlen(szMessage)-1] = '.';
- ColorChat(id, szMessage);
- }
- else ColorChat(id, "Nu sunt jucatori !gON !ncu !gbeneficii !npe server.");
- }
- /* Colorchat Stock */
- stock ColorChat(const id,const input[], any:...)
- {
- new iNum = 1, iPlayers[32];
- static szMessage[191];
- vformat(szMessage, charsmax(szMessage),input, 3);
- replace_all(szMessage, charsmax(szMessage), "!g", "^4");
- replace_all(szMessage, charsmax(szMessage), "!n", "^1");
- replace_all(szMessage, charsmax(szMessage), "!t", "^3");
- if(id) iPlayers[0] = id
- else get_players(iPlayers, iNum, "ch");
- for(new i = 0; i < iNum; i++)
- {
- if(is_user_connected(iPlayers[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, iPlayers[i]);
- write_byte(iPlayers[i]);
- write_string(szMessage);
- message_end();
- }
- }
- }
- /* Plugin END */
- public plugin_end()
- {
- ArrayDestroy(g_aBenefits);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement