Senior Member
|
07-29-2012
, 14:29
Plusieurs problèmes
|
#1
|
Salut tout le monde, voilà j'avais déjà ouvert un post il y a belle lurette, mais je n'avais pas eu la bonne solution. Je recherchais un plugin pour avoir un défibrillateur, j'ai décidé de le faire moi même ^^, le seul "hic", enfin, il y en à 3:
1) Comment enlever la "bartime" quand le joueur à relâché la touche utiliser ?
2) Les sons émit sont émit depuis le joueur, mais s'il bouge trop, le son s'arrête, c'est ennuyant pour le son quand il l'achète :/, une solution ?
3) Euh, là c'est le problème majeur, "the big problem !", ok y'a l'achat, ok y'a les models, ok y'a les sons, ok y'a tout qui fonctionne, seulement.. je sais pas comment hook un joueur mort ! x) quand j'ai commencé le plugin, j'me suis dit que j'allais utiliser le get_user_aiming, mais c'est pour les joueurs vivant :/, donc j'me suis dit, j'vais hook un model :p, mais sur mon serveur y'a des skins admins et tout et tout... Donc je sais pas comment faire :/
4) Pendant qu'on y est, vu que je fais toujours des erreurs, si vous voyez des erreurs grotesques, faites-moi signe :p
PHP Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #include <fun> #include <cstrike>
new cvar_defcost new has_def[33]
new const g_model_p_def[] = "models/defibrillateur/p_defibrillateur.mdl" new const g_model_v_def[] = "models/defibrillateur/v_defibrillateur.mdl" new const g_model_w_def[] = "models/defibrillateur/w_defibrillateur.mdl"
new const g_sound_buy[] = "defibrillateur/buy.wav" new const g_sound_speaker[] = "defibrillateur/speaker.wav" new const g_sound_def[] = "defibrillateur/defibrillateur.wav" new const g_sound_revived[] = "defibrillateur/revived.wav"
public plugin_init() { register_plugin("Defibrillateur", "1.0", "Daminou") register_event("CurWeapon", "event_curweapon", "b") register_event("DeathMsg", "event_death", "a") register_forward(FM_Touch, "fwd_touch") register_forward(FM_CmdStart,"fwd_cmdstart") register_clcmd("say /def", "buydef") register_clcmd("drop", "hook_drop") cvar_defcost = register_cvar("amx_defcost", "2500") }
public plugin_precache() { precache_model(g_model_p_def) precache_model(g_model_v_def) precache_model(g_model_w_def) precache_sound(g_sound_buy) precache_sound(g_sound_speaker) precache_sound(g_sound_def) precache_sound(g_sound_revived) }
public client_disconnect(id) { has_def[id] = false }
public buydef(id) { if(!is_user_alive(id)) { client_print(id, print_chat, "Tu dois etres vivant pour acheter un defibrillateur.") return PLUGIN_HANDLED } if(has_def[id]) { client_print(id, print_chat, "Tu as deja un defibrillateur.") return PLUGIN_HANDLED } new user_money = cs_get_user_money(id) new def_cost = get_pcvar_num(cvar_defcost) if(user_money < def_cost) { client_print(id, print_chat, "Tu n'as pas assez d'argent pour acheter un defibrillateur.") return PLUGIN_HANDLED } cs_set_user_money(id, user_money - def_cost) has_def[id] = true engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_buy, 1.0, ATTN_NORM, 0, PITCH_NORM) return PLUGIN_HANDLED }
public event_death() { new Float:velo[3] new victim = read_data(2) create_def(victim, velo) has_def[victim] = false return PLUGIN_CONTINUE }
public event_curweapon(id) { if(!is_user_alive(id) || !has_def[id]) return PLUGIN_HANDLED; new weapon, clip, ammo weapon = get_user_weapon(id, clip, ammo) if(weapon == CSW_KNIFE) { set_pev(id, pev_viewmodel2, g_model_v_def) set_pev(id, pev_weaponmodel2, g_model_p_def) } return PLUGIN_HANDLED }
public fwd_cmdstart(id, uc_handle, seed) { if(!is_user_alive(id) || !has_def[id]) return FMRES_IGNORED; new weapon, clip, ammo weapon = get_user_weapon(id, clip, ammo) if(weapon != CSW_KNIFE) return FMRES_IGNORED; new button = get_uc(uc_handle, UC_Buttons) if(button & IN_USE) { message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("BarTime"), {0,0,0}, id); write_short(5) message_end() } return FMRES_HANDLED }
public fwd_touch(touched, toucher) { if(!pev_valid(touched) || !is_user_alive(toucher)) return FMRES_IGNORED; new classname[32] pev(touched, pev_classname, classname, sizeof classname - 1) if(equali(classname, "defibrillateur")) { if(has_def[toucher]) return FMRES_IGNORED; if(pev_valid(touched)) { engfunc(EngFunc_RemoveEntity, touched) } has_def[toucher] = true client_print(toucher, print_chat, "Tu as trouver un defibrillateur !") engfunc(EngFunc_EmitSound, toucher, CHAN_BODY, g_sound_buy, 1.0, ATTN_NORM, 0, PITCH_NORM) } return FMRES_IGNORED }
public hook_drop(id) { if(!has_def[id]) return PLUGIN_CONTINUE; new Float:velo[3] new weapon, clip, ammo weapon = get_user_weapon(id, clip, ammo) if(weapon == CSW_KNIFE) { velocity_by_aim(id, 200, velo) create_def(id, velo) has_def[id] = false } return PLUGIN_CONTINUE }
public create_def(id, Float:velo[]) { new Float:origin[3] new Float:angles[3] new Float:mins[3] = {-2.79, -0.0, -6.14} new Float:maxs[3] = {2.42, 1.99, 6.35} new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")) if(!is_user_alive(id)) { velo[0] = random_float(1.0, 150.0) velo[1] = random_float(1.0, 150.0) velo[2] = random_float(1.0, 150.0) } else { velo[2] += 100 } pev(ent, pev_angles, angles) angles[1] += random_num(1, 360) pev(id, pev_origin, origin) set_pev(ent, pev_origin, origin) set_pev(ent, pev_classname, "defibrillateur") engfunc(EngFunc_SetModel, ent, g_model_w_def) engfunc(EngFunc_SetSize, ent, mins, maxs) set_pev(ent, pev_angles, angles) set_pev(ent, pev_solid, SOLID_TRIGGER) set_pev(ent, pev_movetype, MOVETYPE_TOSS) set_pev(ent, pev_velocity, velo) engfunc(EngFunc_DropToFloor, ent) return FMRES_IGNORED }
Merci pour le temps que vous prendrez à répondre :p
__________________
MiniBrackeur => Daminou
Last edited by MiniBrackeur; 07-29-2012 at 14:31.
|
|