AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help [Plugin] (https://forums.alliedmods.net/showthread.php?t=41183)

happycappy 07-10-2006 15:12

Help [Plugin]
 
Its the first time im making a plugin, so don't be to hard on me :P
Im trying to make a plugin to punish people saying lol, so its the SayLolGetSlap plugin. But because its the first time, i screwed something up so it doesnt work.
I used rolnaaba's script , http://forums.alliedmods.net/showthread.php?t=41148 , but im stuck on something , instead of getting hp in that plugin, i wanted to let someone lose hp, so what did i do? I changed the number of health to -1. But somehow, when im testing it, and i say lol, my hp doesnt goes down, and i cant activate it. The other problem is, the slapping effect, if i use this script there wont be slapped, but just -1 hp, so could someone help me with that? Here's the code:
Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {     register_plugin("Say Lol And Get Slapped", "1.0", "eXec")     register_concmd("say lol", "lol")     register_cvar("slaplol_on", "1") } public func_gethp(id) {     if(get_cvar_num("slaplol_on") == 0)     {         return PLUGIN_HANDLED     }         else     {         set_user_health(id, get_user_health(id) - 1)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED     }

Rolnaaba 07-10-2006 15:22

Re: Help [Plugin]
 
Simple use the user_slap comand and set the power to 1
Your Plugin with user_slap:
Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {     register_plugin("Say Lol And Get Slapped", "1.0", "eXec")     register_concmd("say lol", "lol")     register_cvar("slaplol_on", "1") } public func_gethp(id) {     if(get_cvar_num("slaplol_on") == 0)     {         return PLUGIN_HANDLED     }         else     {  user_slap(id,1,rnddir=1)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED     }
that will slap the player and subtract 1 point of damage from their health :)

Hawk552 07-10-2006 15:24

Re: Help [Plugin]
 
Don't read his tutorial. It sucks. Seriously. Read another one.

But for a quick fix,

Code:
#include <amxmodx> #include <amxmisc> #include <fun>   public plugin_init() {         register_plugin("Say Lol And Get Slapped", "1.0", "eXec")         register_concmd("say lol", "lol")         register_cvar("slaplol_on", "1") } public lol(id)     if(get_cvar_num("slaplol_on"))         set_user_health(id, get_user_health(id) - 1)

Des12 07-10-2006 16:12

Re: Help [Plugin]
 
If you didnt understand that,

your register:
register_concmd("say lol", "lol")

your function:
public func_gethp(id)

you need the second argument to match the function, as Hawk showed

so:

register_concmd("say lol", "func_gethp")

public func_gethp(id)

Rolnaaba 07-10-2006 16:23

Re: Help [Plugin]
 
hawk he can get the subtraction of hp to work the whole problem was it didnt slap the person so what you posted only fixs a typo i wrote and does nothing to help his problem
Code:
#include <amxmodx> #include <amxmisc> #include <fun>   public plugin_init() {         register_plugin("Say Lol And Get Slapped", "1.0", "eXec")         register_concmd("say lol", "lol")         register_cvar("slaplol_on", "1") } public lol(id)     if(get_cvar_num("slaplol_on"))         user_slap(id,1)
will work

Hawk552 07-10-2006 16:46

Re: Help [Plugin]
 
Actually both work, and it's not a typo, you made a horribly inefficient script. I really wish you'd just stop helping people until you really understand Pawn, because right now you don't, and you're misleading so many people that way.

v3x 07-10-2006 18:36

Re: Help [Plugin]
 
Quote:

Originally Posted by Hawk552
Actually both work, and it's not a typo, you made a horribly inefficient script. I really wish you'd just stop helping people until you really understand Pawn, because right now you don't, and you're misleading so many people that way.

Exactly. Couldn't of put it in better words myself ;)

Rolnaaba 07-10-2006 20:14

Re: Help [Plugin]
 
hawk on ur post all u did was fix my typo of typing:
Code:
public func_gethp()
instead
Code:
public lol()
this was what i was speaking of

Hawk552 07-10-2006 20:22

Re: Help [Plugin]
 
Quote:

Originally Posted by Rolnaaba
hawk on ur post all u did was fix my typo of typing:
Code:
public func_gethp()

instead
Code:
public lol()

this was what i was speaking of

Yes, that's a typo, but your script was still horribly inefficient. As I said, just stop helping people until you actually learn how to script.

happycappy 07-11-2006 04:33

Re: Help [Plugin]
 
Thank you very much guys :D You really helped me out :D

Edit: Ok, now the next thing actually is, that when he get slapped of saying lol, i want to be said : "Player" got slapped because he said lol. How to do that? I know i got t learn scripting myself, but please show me .

Btw, in the script there is PLUGIN_HANDLED, shouldnt it be PLUGIN_CONTINOUED?


All times are GMT -4. The time now is 08:05.

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