AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   My First Plugin (https://forums.alliedmods.net/showthread.php?t=98520)

nwQ 07-26-2009 07:43

My First Plugin
 
Hello. It's my first plugin, and I don't know, what I do wrong :(
Can anybody help me?
Quote:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define PLUGIN "IDK"
#define VERSION "1.0"
#define AUTHOR "nwQ"


public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /lol","hpa")
register_clcmd("say lol","hpa")
}
public hpa(id) {
new Heath = get_user_health(id);
new randomNum = random_num(1, 10);
if(!is_user_alive(id))
client_print(id,print_center,"Jestes martwy stary xP");
switch(randomNum)
{
case 0:
{
give_item(id,"ak47");
client_print(0,print_chat,"Dostales AK xD");

}
case 1:
{
set_user_health(id,Heath + 149);
client_print(id,print_center,"Dostales zycie xP");
}
case 2:
{
give_item(id,"m4a1");
client_print(id,print_chat,"Dostales M4 xD")
}
}
return PLUGIN_HANDLED
}
Pleeeaaseeee :oops::mrgreen:

hleV 07-26-2009 07:51

Re: My First Plugin
 
Here. Analyze what I did with the code.
Code:
#include <amxmodx> #include <amxmisc> #include <fun>   #define PLUGIN "IDK" #define VERSION "1.0" #define AUTHOR "nwQ"   public plugin_init() {         register_plugin(PLUGIN, VERSION, AUTHOR)         register_clcmd("say /lol","hpa")         register_clcmd("say lol","hpa") }   public hpa(id) {         new Heath = get_user_health(id);         new randomNum = random(3);           if(!is_user_alive(id))         {                 client_print(id,print_center,"Jestes martwy stary xP");                   return PLUGIN_HANDLED;         }           switch(randomNum)         {                 case 0:                 {                         give_item(id,"weapon_ak47");                         client_print(0,print_chat,"Dostales AK xD");                 }                 case 1:                 {                         set_user_health(id,Heath + 149);                         client_print(id,print_center,"Dostales zycie xP");                 }                 case 2:                 {                         give_item(id,"weapon_m4a1");                         client_print(id,print_chat,"Dostales M4 xD")                 }         }           return PLUGIN_HANDLED }

nwQ 07-26-2009 07:57

Re: My First Plugin
 
I analyze but I edit my plug, correct errors, and I put to plugins in amxmodx and it doesn't works :(
@edit
And I wrote to plugins.ini lol.amxx
@edit
sorry :( i don't turn on modules because i don't have them :/
I'll edit this post, when I find modules, and check.
And thanks for help :)

hleV 07-26-2009 08:18

Re: My First Plugin
 
I posted the code that actually should work. I just told you to analyze it so you would understand what I've done.

nwQ 07-26-2009 08:53

Re: My First Plugin
 
sorry, i had turn off modules :(
I turned it on, and plugin work, but when I wrote `lol` to chat, plugin don't gave me hp, or m4, or ak :( any ideas?

------
sorry, my english is bad :(

fysiks 07-26-2009 20:15

Re: My First Plugin
 
Quote:

Originally Posted by nwQ (Post 882135)
sorry, i had turn off modules :(
I turned it on, and plugin work, but when I wrote `lol` to chat, plugin don't gave me hp, or m4, or ak :( any ideas?

------
sorry, my english is bad :(

Whose code are you using? In your code there exists the possibility of not getting anything (70% of the time).


All times are GMT -4. The time now is 18:17.

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