- | Afiseaza codul
[#include <amxmodx> #include <fakemeta> #include <hamsandwich> #define PLUGIN "Coins System" #define VERSION "1.0" #define AUTHOR "6u3oH" #define CLASSNAME_DEFAULT "info_null" #define CLASSNAME_SET "info_coin" #define PATH_DATABASE "addons/amxmodx/data/coins_system.dat" #define COIN_MODEL "models/coin/mario_coin.mdl" #define COIN_SOUND "coin/coin.wav" #define PDATA_KILLHEAD_OFFSET 75 #define PDATA_KILLGREN_OFFSET 76 #define PDATA_PLAYER_OFFSET 5 /*---------------------------------------------------------- ------------------------ ????????? ------------------------ ---------------------------------------------------------*/ #define VIP_FLAG ADMIN_LEVEL_H #define COIN_GIVE_KILL 0 // Wie viele Münzen für einen einfachen Kill geben sollen #define COIN_GIVE_KILL_HEAD 1 // Wie viele Münzen für einen Kill am Kopf geben sollen #define COIN_GIVE_KILL_KNIFE 1 // Wie viele Münzen für einen Messertod geben sollen #define COIN_GIVE_KILL_GRENADE 1 // Wie viele Münzen zum Töten einer Granate geben sollen #define COIN_DROP_COINS // Kommentiere die Zeile aus, damit keine Münzen aus dem Player fallen #define COIN_NUM_DROPKILL_MIN 1 // Die Mindestanzahl an Münzen, die fallen, wenn ein Spieler stirbt #define COIN_NUM_DROPKILL_MAX 2 // Die maximale Anzahl von Münzen, die fallen, wenn ein Spieler stirbt #define COIN_TIME_REMOVE 10 // Nach wie vielen Sekunden werden die abgelegten Münzen entfernt (auskommentieren, damit sie erst am Ende der Runde entfernt werden) /*---------------------------------------------------------- ------------------------ ????????? ------------------------ ---------------------------------------------------------*/ new g_iMaxPlayers; new g_iCoin[33]; public plugin_precache() { precache_model(COIN_MODEL); precache_sound(COIN_SOUND); } public plugin_cfg() write_file(PATH_DATABASE, "[Datenbank] [Coins System]", 0); public client_connect(id) load_coins(id); public client_disconnected(id) save_coins(id); public plugin_natives() { register_native("get_user_coins", "get_user_coins", true) register_native("set_user_coins", "set_user_coins", true) } public get_user_coins(id) return g_iCoin[id]; public set_user_coins(id, iNum) g_iCoin[id] = iNum; public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR); #if defined COIN_DROP_COINS RegisterHam(Ham_Killed, "player", "fw_KilledPlayerPost", true); #endif RegisterHam(Ham_Touch, CLASSNAME_DEFAULT, "fw_TouchCoinPost", true); #if defined COIN_TIME_REMOVE RegisterHam(Ham_Think, CLASSNAME_DEFAULT, "fw_ThinkCoinPost", true); #endif register_logevent("event_RoundEnd", 2, "1=Round_End"); g_iMaxPlayers = get_maxplayers(); set_task(2.0, "Task_HudMsg", .flags = "b"); } #if defined COIN_DROP_COINS public fw_KilledPlayerPost(iVictim, iAttacker, iCorpse) { if(!is_user_connected(iVictim)) return; if(g_iCoin[iVictim] > 0) { new Float: fOrigin[3], Float: fVelocity[3]; pev(iVictim, pev_origin, fOrigin); new iRandom = random_num(COIN_NUM_DROPKILL_MIN, COIN_NUM_DROPKILL_MAX); for(new i; i <= iRandom; i++) { if(!g_iCoin[iVictim]) return; new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, CLASSNAME_DEFAULT)); set_pev(iEnt, pev_classname, CLASSNAME_SET); set_pev(iEnt, pev_origin, fOrigin); set_pev(iEnt, pev_solid, SOLID_TRIGGER); set_pev(iEnt, pev_movetype, MOVETYPE_BOUNCE); engfunc(EngFunc_SetSize, iEnt, Float: {-10.0, -10.0, -10.0}, Float: {10.0, 10.0, 10.0}); engfunc(EngFunc_SetModel, iEnt, COIN_MODEL); fVelocity[0] = random_float(10.0, 50.0); fVelocity[1] = random_float(10.0, 50.0); fVelocity[2] = random_float(100.0, 150.0); set_pev(iEnt, pev_velocity, fVelocity); #if defined COIN_TIME_REMOVE set_pev(iEnt, pev_nextthink, get_gametime() + COIN_TIME_REMOVE); #endif } } if(!is_user_connected(iAttacker)) return; if(iVictim == iAttacker) return; new iGiveCoin = g_iCoin[iAttacker]; if(get_pdata_int(iVictim, PDATA_KILLGREN_OFFSET) & DMG_GRENADE) g_iCoin[iAttacker] += COIN_GIVE_KILL_GRENADE; else if(iAttacker == pev(iVictim, pev_dmg_inflictor) && get_user_weapon(iAttacker) == CSW_KNIFE) g_iCoin[iAttacker] += COIN_GIVE_KILL_KNIFE; else if(get_pdata_int(iVictim, PDATA_KILLHEAD_OFFSET, PDATA_PLAYER_OFFSET) == HIT_HEAD) g_iCoin[iAttacker] += COIN_GIVE_KILL_HEAD; else g_iCoin[iAttacker] += COIN_GIVE_KILL; if(get_user_flags(iAttacker) & VIP_FLAG) g_iCoin[iAttacker] *= 2; iGiveCoin = g_iCoin[iAttacker] - iGiveCoin; set_hudmessage(0, 255, 0, -1.0, 0.26, 0, 0.1, 2.0, 0.1, 0.1, 3); show_hudmessage(iAttacker, "+%i ?????", iGiveCoin); } public fw_TouchCoinPost(iEnt, id) { if(!pev_valid(iEnt) || !is_user_alive(id)) return; static sClassName[32]; pev(iEnt, pev_classname, sClassName, charsmax(sClassName)); if(!equal(sClassName, CLASSNAME_SET)) return; g_iCoin[id]++; emit_sound(id, CHAN_WEAPON, COIN_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM); set_pev(iEnt, pev_flags, pev(iEnt, pev_flags) | FL_KILLME); } #endif #if defined COIN_TIME_REMOVE public fw_ThinkCoinPost(iEnt) { if(!pev_valid(iEnt)) return; static sClassName[32]; pev(iEnt, pev_classname, sClassName, charsmax(sClassName)); if(!equal(sClassName, CLASSNAME_SET)) return; set_pev(iEnt, pev_flags, pev(iEnt, pev_flags) | FL_KILLME); } #endif public event_RoundEnd() { new iEnt = FM_NULLENT; while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", CLASSNAME_SET))) if(pev_valid(iEnt)) set_pev(iEnt, pev_flags, pev(iEnt, pev_flags) | FL_KILLME); } public Task_HudMsg() { set_hudmessage(200, 200, 200, 0.01, 0.90, 0, 0.1, 1.0, 0.1, 0.1, 4); for(new id = 1; id < g_iMaxPlayers; id++) { if(!is_user_alive(id)) continue; show_hudmessage(id, "???? ??????: %i", g_iCoin[id]); } } public load_coins(id) { new iLine = 1, iLen, sData[64], sKey[38], sAuthID[38]; get_user_authid(id, sAuthID, charsmax(sAuthID)); while((iLine = read_file(PATH_DATABASE, iLine, sData, charsmax(sData), iLen))) { parse(sData, sKey, 37); if(equal(sKey, sAuthID)) { parse(sData, sKey, 37, sKey, 37); g_iCoin[id] = str_to_num(sKey); return; } } g_iCoin[id] = 0; } public save_coins(id) { new iLine = 1, iLen, sData[64], sKey[38], sAuthID[38]; get_user_authid(id, sAuthID, charsmax(sAuthID)); while((iLine = read_file(PATH_DATABASE, iLine, sData, charsmax(sData), iLen))) { parse(sData, sKey, 37); if(equal(sKey, sAuthID)) { format(sData, charsmax(sData), "%s %i", sAuthID, g_iCoin[id]); write_file(PATH_DATABASE, sData, iLine-1); return; } } format(sData, charsmax(sData), "%s %i", sAuthID, g_iCoin[id]); write_file(PATH_DATABASE, sData, -1); }
Coin Plugin Problem FIX
Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com
-
- Membru, skill +1
- Posts: 228
- Joined: 11 Feb 2017, 12:13
- Detinator Steam: Nu
- CS Status: Citesc forumul eXtreamCS.com...!
- Fond eXtream: 0
- Has thanked: 2 times
- Contact:
Hello, I have a big problem with this plugin. Officially, the plugin should work as follows: You or someone kills a player, the killed player sometimes loses coins that are lying on the floor/ground. Now you should run to the coins and collect these coins. Then you get 1 coin by 1 coin. It also works, but the big problem is this: If you kill someone, you will automatically be credited with coins, sometimes 25, sometimes 65 and so on. Can someone help me or tell me how to fix the problem?