AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Simple plugin help. (https://forums.alliedmods.net/showthread.php?t=47430)

dongfatt 11-17-2006 16:56

Simple plugin help.
 
[code]
#include <amxmodx>
#include <fun>

new bool:fart[33]

public plugin_init()
{
register_plugin(Sound, 1.00, Mike)
register_clcmd("say /fart","Fart")
}

public plugin_precache()
{
precache_sound("fart.wav")
}

public client_connect(id)
{
fart[id]=false
}

public client_disconnect(id)
{
fart[id]=false
}

public fart(id)
{
if(!fart[id])
{
client_print(id,print_chat,"You Have Just Farted."
}
else
{
fart[id]=false
}
return PLUGIN_HANDLED

I do not know what else i have to do in order to make it so that every time a player dies it makes a fart sound, this plugin is for learning how to become a better coder. Thank in advance.

Da_sk8rboy 11-17-2006 17:02

Re: Simple plugin help.
 
please you small:

Code:
 #include <amxmodx> #include <fun> new bool:fart[33] public plugin_init() {     register_plugin(Sound, 1.00, Mike)     register_clcmd("say /fart","Fart") } public plugin_precache() {     precache_sound("fart.wav") } public client_connect(id) {     fart[id]=false } public client_disconnect(id) {     fart[id]=false } public fart(id) {     if(!fart[id])     {         client_print(id,print_chat,"You Have Just Farted."     }     else     {         fart[id]=false     }     return PLUGIN_HANDLED

The Specialist 11-17-2006 17:04

Re: Simple plugin help.
 
you need a death message to find out when the player dies then play the sound in the hooked message. you also dont need to do a client connect or disconenct. its not necesary. alot of un-needed code .:wink:

dongfatt 11-17-2006 17:20

Re: Simple plugin help.
 
thanks for the reply but i need help with the whole plugin :( since i put alot of unnecessary stuff in there i don't know how to fix it.

dongfatt 11-17-2006 17:50

Re: Simple plugin help.
 
thanks for your reply.

Da_sk8rboy 11-17-2006 17:53

Re: Simple plugin help.
 
Code:
public plugin_precache() {         precache_sound("myfolder/mysound.wav")         // = modfolder/sound/myfolder/mysound.wav         // Note that some Sounds are precached by the Game already }   public something(id) {         emit_sound(id,4,"myfolder/mysound.wav",0.7,0.8,0,100)         // Will play a Sound at the Origin of the Player with given ID. Use id 0 to play to everyone               // OR         client_cmd("play myfolder/mysound.wav")         // Plays a Sound that only this client can hear.         // You can use id 0 here, too, which is better than emit_sound with id 0, because this will have Mono effect. }

dutchmeat 11-20-2006 03:46

Re: Simple plugin help.
 
Code:
#include <amxmodx> #include <fun> new bool:fart[33] public plugin_init() {     register_plugin("FartMode", 1.00, "Mike")     register_clcmd("say /fart","Fart")     register_message(get_user_msgid("DeathMsg"), "deathmessage") } public plugin_precache() {     precache_sound("fart.wav") } public client_connect(id) {     fart[id]=false } public client_disconnect(id) {     fart[id]=false } public fart(id) {     if(!fart[id])     {         client_print(id,print_chat,"FartingMode is On."     }     else     {         fart[id]=false              client_print(id,print_chat,"FartingMode is Off."     }     return PLUGIN_HANDLED } public deathmessage(msg_id, msg_dest, msg_entity){ //new killer = get_msg_arg_int(1) this is the killer,but we won't need it. new victim = get_msg_arg_int(2) //the victim, we need this. if (victim != -1 && fart[victim]){ //prevent a certain crash, wich happens when this message is called 3 times(one with the true victim id, and others are -1). //fart[victim] is a check if the 'farting mode' is enabled. emit_sound(victim,CHAN_BODY, "fart.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) //fart! //fart[victim] = 0 this way you can disable the fartingmode at death, but you'll have to enable the mode each time. }

SSJ2GOKU 11-20-2006 04:47

Re: Simple plugin help.
 
made it more readable + corrected an error on the end of the plugin

Code:
#include <amxmodx> #include <fun> new bool:fart[33] public plugin_init() {     register_plugin("FartMode", 1.00, "Mike")     register_clcmd("say /fart","Fart")     register_message(get_user_msgid("DeathMsg"), "deathmessage") } public plugin_precache() {     precache_sound("fart.wav") } public client_connect(id) {     fart[id]=false } public client_disconnect(id) {     fart[id]=false } public fart(id) {     if(!fart[id])     {         client_print(id,print_chat,"FartingMode is On."     }     else     {         fart[id]=false         client_print(id,print_chat,"FartingMode is Off."     }     return PLUGIN_HANDLED } public deathmessage(msg_id, msg_dest, msg_entity){     new victim = get_msg_arg_int(2)     if (victim != -1 && fart[victim]){         emit_sound(victim,CHAN_BODY, "fart.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)     } }

dutchmeat 11-20-2006 05:43

Re: Simple plugin help.
 
you added a last branch, and removed all my comment quotes?

[ --<-@ ] Black Rose 11-20-2006 12:22

Re: Simple plugin help.
 
better?
Code:
#include <amxmodx> new bool:fart[33] public plugin_init() {     register_plugin("FartMode", "1.00", "Mike")     register_clcmd("say /fart","cmd_fart")     register_event("DeathMsg", "deathmessage", "a") } public plugin_precache()     precache_sound("fart.wav") public client_connect(id)     fart[id] = false public client_disconnect(id)     fart[id] = false public cmd_fart(id) {     if ( ! fart[id] )         client_print(id,print_chat,"FartingMode is On.")         else {         fart[id] = false         client_print(id,print_chat,"FartingMode is Off.")     }         return PLUGIN_HANDLED } public event_DeathMsg() {         new victim = read_data(2)         if ( victim != -1 && fart[victim] )         emit_sound(victim, CHAN_BODY, "fart.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) }


All times are GMT -4. The time now is 06:59.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.