Raised This Month: $ Target: $400
 0% 

Help needed for my plugin!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
chRm
Senior Member
Join Date: Sep 2005
Location: Cyprus
Old 11-09-2005 , 07:54   Help needed for my plugin!
Reply With Quote #1

I made a small plugin just to start learning small but I come against some problems with it, how can i check if pa_lol is set to 0 and then stop the message from appearing whenever i say lol ??

Here's the code:

Code:
/* Plugin generated by AMXX-Studio */ /* My first plugin ever!!! The commands are say lol - shows lol message pa_lol 1|0 - 1 acivates lol message, 0 disables pa_killswitch 1|0 - 1 activates kill, 0 disbles it */ #include <amxmodx> public plugin_init()     {     register_plugin("killer_lol_plug", "0.1 beta", "Panais")     register_clcmd ( "say lol", "saylol", 0,"displays lol function" )     register_cvar ( "pa_lol", "1")     register_cvar ("pa_killswitch", "1")     register_concmd("pa_kill","do_kill",ADMIN_LEVEL_C," Kills people ") } public saylol(id) {     if (get_cvar_num("pa_lol")==1)//to display message     set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0)     show_hudmessage(id, "I said lol :):):)")     return PLUGIN_HANDLED } public do_kill(id) { //kill function         if (get_cvar_num("pa_killswitch")==0) {         return PLUGIN_HANDLED     }         if (!(get_user_flags(id)&ADMIN_KICK)) {         console_print(id,"You have no access")         return PLUGIN_HANDLED     }     if (read_argc() == 0) { //verifies user 1         console_print(id,"You must specify a user first.")         return PLUGIN_HANDLED     }     new user[32], uid //verifies user 2     read_argv(1,user,32)     uid = find_player("bh",user)     if (uid == 0) {         console_print(id,"Invalid userid, please try again.")         return PLUGIN_HANDLED     }     user_kill (uid)     return PLUGIN_HANDLED }
__________________
This signature is going to self destruct in: <countdown coming soon>




Previously known as Panais
chRm is offline
Send a message via MSN to chRm
haimmaik
Senior Member
Join Date: Jul 2005
Old 11-09-2005 , 08:14  
Reply With Quote #2

hmm.. im not sure what u want but i think that will do the job

Code:
public saylol(id) {     if (get_cvar_num("pa_lol")==1)//to display message     {     set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0)     show_hudmessage(id, "I said lol ")     return PLUGIN_HANDLED     } return PLUGIN_HANDLED }

you need to add {} after if.. to include all the commands after it inside the if... (like in a function)
haimmaik is offline
chRm
Senior Member
Join Date: Sep 2005
Location: Cyprus
Old 11-09-2005 , 08:28  
Reply With Quote #3

I'm just starting to learn but do you mean like this?

Code:
public saylol(id) {       if (get_cvar_num("pa_lol")==1){pa_lol}//to display message       {     set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0)       show_hudmessage(id, "I said lol ")       return PLUGIN_HANDLED       } }
Note the {pa_lol}
__________________
This signature is going to self destruct in: <countdown coming soon>




Previously known as Panais
chRm is offline
Send a message via MSN to chRm
haimmaik
Senior Member
Join Date: Jul 2005
Old 11-09-2005 , 08:32  
Reply With Quote #4

no look
treat the
Code:
if (get_cvar_num("pa_lol")==1)
as it was a function

in a function its:
Code:
public name(args) {     // Begin   ... //everything inside the function }    //End

you also need begin and end to the if thing...
and also need to return PLUGIN_HANDLED outside the "if". so ur function should look like that

Code:
 public saylol(id) {       if (get_cvar_num("pa_lol")==1)//to display message       {     set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0)       show_hudmessage(id, "I said lol ")       return PLUGIN_HANDLED       } return PLUGIN_HANDLED   }

NOTE:
IF has the same structure of a FUNCTION
haimmaik is offline
chRm
Senior Member
Join Date: Sep 2005
Location: Cyprus
Old 11-09-2005 , 10:07  
Reply With Quote #5

Oh now I understand. Thanks
__________________
This signature is going to self destruct in: <countdown coming soon>




Previously known as Panais
chRm is offline
Send a message via MSN to chRm
haimmaik
Senior Member
Join Date: Jul 2005
Old 11-09-2005 , 11:08  
Reply With Quote #6

np
haimmaik is offline
Charr
Senior Member
Join Date: Jul 2005
Location: Long Island, New York, U
Old 11-09-2005 , 15:15  
Reply With Quote #7

Code:
 public saylol(id) {       if (get_cvar_num("pa_lol")==1)//to display message       {     set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0)       show_hudmessage(id, "I said lol ")       return PLUGIN_HANDLED       } return PLUGIN_HANDLED   }
Should be:
Code:
 public saylol(id) {       if (get_cvar_num("pa_lol")==1)//to display message       {        set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0)          show_hudmessage(id, "I said lol ")          return PLUGIN_HANDLED       } return PLUGIN_HANDLED   }
__________________
Charr is offline
Send a message via AIM to Charr Send a message via MSN to Charr
chRm
Senior Member
Join Date: Sep 2005
Location: Cyprus
Old 11-10-2005 , 07:47  
Reply With Quote #8

Isn't it the same except for the extra spaces?
__________________
This signature is going to self destruct in: <countdown coming soon>




Previously known as Panais
chRm is offline
Send a message via MSN to chRm
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-10-2005 , 11:42  
Reply With Quote #9

yes.
[ --<-@ ] Black Rose is offline
Charr
Senior Member
Join Date: Jul 2005
Location: Long Island, New York, U
Old 11-10-2005 , 12:13  
Reply With Quote #10

The second is properly idented, the first is not.

This is what happens when you don't ident right:
Code:
Warning: Loose Indentation
__________________
Charr is offline
Send a message via AIM to Charr Send a message via MSN to Charr
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:36.


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