AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Please Help me on plugins. (https://forums.alliedmods.net/showthread.php?t=29252)

Chex 06-01-2006 22:49

Please Help me on plugins.
 
Hi.
I am new to small and I need a little bit of help. I am trying to get a plugin that if you type /frisk you get the number of guns the player has. I have tryed many thing but they do not work. Can I get a little bit of help?
Code:
    }     new weaponsid     new id, clip, ammo, mode, extra     weaponsid = ts_getuserwpn(id,clip,ammo,mode,extra)     client_print(id,print_chat,"Player has %i weapon(s).^n",weaponsid)     return PLUGIN_HANDLED }
Thank you for you time.

Caesar 06-02-2006 01:47

Im kinda noob at the scripting thing too but it looks like your setting your variables to nothing

shouldn't it be

new id, blah, blah = (something)????

Chex 06-02-2006 02:05

Like they all start off to be zero? That may be a reason.

Edit: Well that does not work but thanks for the try.

I have it working enough for it to register if there is not a gun. But I just found out that ts_getuserwpn finds a single weapon or some thing along those lines. So is there a way to code some thing like this?

if (weaponsid = 0) {
client_print(id,print_chat,"Player does not have a weapon.")
}

Again thank you for your help.

p3tsin 06-02-2006 04:38

not sure about ts, but maybe this works :)
Code:
public func(id) {     new weapons[32], num     get_user_weapons(id, weapons,num)     client_print(id,print_chat, "You have %d weapons",num) }

Chex 06-02-2006 19:09

Nope, get_user_weapons does not work on ts. But thanks for the help.

v3x 06-02-2006 19:12

At least show us (1) the full code or (2) the whole function.

Chex 06-03-2006 00:21

Sorry.
Code:
#include <amxmodx> #include <amxmisc> #include <tsfun> #include <tsxaddon> #define PLUGIN "Frisker" #define VERSION "1.0" #define AUTHOR "Chexmix" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_concmd("/frisk", "check", ADMIN_IMMUNITY )     } public check (id)     {     if(!(get_user_flags(id) & ADMIN_IMMUNITY)) {         client_print(id, print_console, "You do not have access to this command!^n")         return PLUGIN_HANDLED     }     new entid, entbody     get_user_aiming(id,entid,entbody,100)     if(!is_user_connected(entid)){         client_print(id,print_chat,"Trust me, the air does not have any guns!^n")         return PLUGIN_HANDLED     }     new weaponsid         new id, clip = 0, ammo =0, mode = 0, extra = 0         weaponsid = ts_getuserwpn(entid,clip,ammo,mode,extra)         client_print(id,print_chat,"Player has %i weapon(s).^n",weaponsid)             if(weaponsid = 0){                 client_print(id,print_chat,"The player does not have any thing him.")     }     if(weaponsid = 1) {         client_print(id,print_chat,"You do not find any thing.^n*")                 return PLUGIN_HANDLED     } }

I have been testing with diffrent things so some things are there that don't need to be.

v3x 06-03-2006 00:37

I added comments so you would know what I did.
Code:
#include <amxmodx> #include <amxmisc> #include <tsfun> #include <tsxaddon> #define PLUGIN "Frisker" #define VERSION "1.0" #define AUTHOR "Chexmix" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_concmd("say /frisk", "check", ADMIN_IMMUNITY ) // added "say " } public check(id) {     if(!(get_user_flags(id) & ADMIN_IMMUNITY)) {         client_print(id, print_console, "You do not have access to this command!^n")         return PLUGIN_HANDLED     }     new entid, entbody     get_user_aiming(id,entid,entbody,100)     if(!is_user_alive(entid)) { // changed to !is_user_alive instead of !is_user_connected         client_print(id,print_chat,"Trust me, the air does not have any guns!^n")         return PLUGIN_HANDLED     }     new weaponsid         new id, clip = 0, ammo =0, mode = 0, extra = 0         weaponsid = ts_getuserwpn(entid,clip,ammo,mode,extra)         client_print(id,print_chat,"Player has %i weapon%s.^n",weaponsid,(!weaponsid || weaponsid > 1) ? "s" : "")     // if you need me to explain what I did here I will ;-)         if(weaponsid == 0) { // added an extra =         client_print(id,print_chat,"The player does not have any thing him.")         return PLUGIN_HANDLED // added this return     }     if(weaponsid == 1) { // added an extra =         client_print(id,print_chat,"You do not find any thing.^n*")         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED // added this return }
I also cleaned up the code a little bit ;)

Chex 06-03-2006 00:45

Thank you so much! If this works I will put the little v3x is a PIMP thing in my sig. :D

Also please do tell me what you did there, because I am new to scripting and want to learn how to do the best I can. Thank you again.

Edit: Some thing is wrong with the
Code:
if(weaponsid == 1) {
If the person does not have guns it prints the msg about weaponsid ==0. But if the person does have a gun it does not say any thing.

Chex 06-03-2006 01:09

Ok I just had to change it to weaponsid >= 1. Again thank you very much for your help.

I have a new problem now. When a person picks up a gun and then drops it, weaponsid does not seem to go back to 0. So even if they do not have a gun it will still say they do.


All times are GMT -4. The time now is 16:32.

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