Witam, mam plugin "Santa Hat" napisany przez xPaw w wersji 1.3 i chcialem go przerobic by moc wlaczac/wylaczac czapki.
Problem w tym ze po wlaczeniu czapki, potem nie da sie jej wylaczyc.
Po wpisaniu /hats ladnie pokazuje na czacie ze czapka zostala dodana i ja dodaje,
ale natomiast po wpisaniu znow /hats nie usuwa jej ale pisze ze zostala usunieta
Przy kompilacji nie mam zadnych bledow oraz nie mam zadnych bledow w logach.
#include <amxmodx> #include <engine> #include <fakemeta> new const MODEL[] = "models/santa_hat.mdl"; new szHats[33]; new iEntity, iMaxPlayers, iInfoTarget; public plugin_precache() { precache_model(MODEL); } public client_connect(id) { szHats[id] = 0; } public plugin_init() { new const VERSION[] = "1.3"; register_plugin("Santa Hat", VERSION, "xPaw"); register_clcmd("say /hats", "ToggleHat"); iInfoTarget = engfunc(EngFunc_AllocString, "info_target"); iMaxPlayers = get_maxplayers(); } public ToggleHat(id) { switch(szHats[id]) { case 0: { AddHat(); } case 1: { RemoveHat(); } } return PLUGIN_HANDLED; } AddHat() { for(new id = 1; id <= iMaxPlayers; id++) { iEntity = engfunc(EngFunc_CreateNamedEntity, iInfoTarget); if(pev_valid(iEntity)) { engfunc(EngFunc_SetModel, iEntity, MODEL); set_pev(iEntity, pev_movetype, MOVETYPE_FOLLOW); set_pev(iEntity, pev_aiment, id); set_pev(iEntity, pev_owner, id); szHats[id] = 1; client_print(id, print_chat, "Your hat has been added"); } } } RemoveHat() { for(new id = 1; id <= iMaxPlayers; id++) { iEntity = engfunc(EngFunc_FindEntityByString, id, "classname", iInfoTarget); engfunc(EngFunc_RemoveEntity, iEntity); szHats[id] = 0; client_print(id, print_chat, "Your hat has been removed"); } }