AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [solved]ts_giveweapon() 'extra' MUST be a variable (https://forums.alliedmods.net/showthread.php?t=45403)

stupok 10-01-2006 14:57

[solved]ts_giveweapon() 'extra' MUST be a variable
 
I have been running a TS server since before AMXX 1.5, and have never had a problem with ts_giveweapon ( index, weapon, clips, extra )

Now, the plugin below does not give the 'extra' part of the function. The weapon is given, with the correct amount of clips, but no silencer, flashlight, laser, or scope is added. The already approved plugin for ts_giveweapon (search the plugins) does work, meaning it adds the silencer, laser, flashlight or scope. But, it has malfunctioned more than once. For example, I tried several different values for the extra, but it kept giving a weapon with a flashlight.

Besides any insights as to why 'extra' may not work, I'd appreciate some feedback on optimizing this plugin.

Code:
Code:
#include <amxmodx> #include <amxmisc> #include <tsfun> #define PLUGIN "Kwik Weps" #define VERSION "1.0" #define AUTHOR "Kamil" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_concmd("say /ruger","say_ruger")     register_concmd("say /deagle","say_deagle")     register_concmd("say /bull","say_bull")     register_concmd("say /ak","say_ak")     register_concmd("say /m4","say_m4")     register_concmd("say /uzi","say_uzi")     register_concmd("say /socom","say_socom")     register_concmd("say /glock","say_glock")     register_concmd("say /mossberg","say_mossberg")     register_concmd("say /benelli","say_benelli")     register_concmd("say /barrett","say_barrett")     register_concmd("say /tmp","say_tmp")     register_concmd("say /aug","say_aug")     register_concmd("say /usas","say_usas")     register_concmd("say /colts","say_colts")     //register_concmd("say /nade","say_nade")     register_concmd("say /m16","say_m16")     register_concmd("say /mp5sd","say_mp5sd")     register_concmd("say /mp5","say_mp5")     register_concmd("say /57","say_57")     register_concmd("say /berettas","say_berettas")     register_concmd("say /m60","say_m60")     register_concmd("say /spas","say_spas")     register_concmd("say /mp7","say_mp7")     register_concmd("say /guns", "gun_say") } public gun_say(id) {     show_motd(id, "zombie_weapons.txt")     return PLUGIN_HANDLED } public say_ruger(id) {     ts_giveweapon(id, 28, 200, 6)     return PLUGIN_HANDLED } public say_deagle(id) {     ts_giveweapon(id, 12, 200, 6)     return PLUGIN_HANDLED } public say_bull(id) {     ts_giveweapon(id, 31, 200,6)     return PLUGIN_HANDLED } public say_ak(id) {     ts_giveweapon(id, 13, 200,18)     return PLUGIN_HANDLED } public say_m4(id) {     ts_giveweapon(id, 5, 200,18)     return PLUGIN_HANDLED } public say_uzi(id) {     ts_giveweapon(id, 3, 200,6)     return PLUGIN_HANDLED } public say_socom(id) {     ts_giveweapon(id, 9, 200,6)     return PLUGIN_HANDLED } public say_glock(id) {     ts_giveweapon(id, 22, 200,6)     return PLUGIN_HANDLED } public say_mossberg(id) {     ts_giveweapon(id, 26, 200,6)     return PLUGIN_HANDLED } public say_benelli(id) {     ts_giveweapon(id, 4, 200,6)     return PLUGIN_HANDLED } public say_barrett(id) {     ts_giveweapon(id, 18, 200,6)     return PLUGIN_HANDLED } public say_tmp(id) {     ts_giveweapon(id, 17, 200,6)     return PLUGIN_HANDLED } public say_aug(id) {     ts_giveweapon(id, 15, 200,6)     return PLUGIN_HANDLED } public say_usas(id) {     ts_giveweapon(id, 11, 200,6)     return PLUGIN_HANDLED } public say_colts(id) {     ts_giveweapon(id, 21, 200,6)     return PLUGIN_HANDLED } public say_nade(id) {     ts_giveweapon(id, 24, 200,0)     return PLUGIN_HANDLED } public say_m16(id) {     ts_giveweapon(id, 27, 200,18)     return PLUGIN_HANDLED } public say_mp5sd(id) {     ts_giveweapon(id, 6, 200,6)     return PLUGIN_HANDLED } public say_mp5(id) {     ts_giveweapon(id, 7, 200,6)     return PLUGIN_HANDLED } public say_57(id) {     ts_giveweapon(id, 14, 200,6)     return PLUGIN_HANDLED } public say_berettas(id) {     ts_giveweapon(id, 8, 200,6)     return PLUGIN_HANDLED } public say_m60(id) {     ts_giveweapon(id, 32, 200,0)     return PLUGIN_HANDLED } public say_spas(id) {     ts_giveweapon(id, 20, 200,6)     return PLUGIN_HANDLED } public say_mp7(id) {     ts_giveweapon(id, 19, 200, 6)     return PLUGIN_HANDLED }

Silver Dragon 10-01-2006 20:28

Re: ts_giveweapon(index,weapon,clips,extra)
 
Wrong section.

stupok 10-01-2006 21:30

Re: ts_giveweapon(index,weapon,clips,extra)
 
No, it is not the wrong section. The plugin works flawlessly. I do not want any advice how to get it working -- it works. If you feel like it, tell me how to optimize it.

I want to know why extras aren't added to the guns. In previous versions of AMXX it would have worked (I am inclined to believe) because I had no problems with giving weapons via ts_giveweapon() with extras working.

If not here, please tell me which section would be appropriate...

knekter 10-01-2006 22:47

Re: ts_giveweapon(index,weapon,clips,extra)
 
You can do it this way:
Code:
#include <amxmodx> #include <amxmisc> #include <tsfun> #define PLUGIN  "Kwik Weps" #define VERSION "1.0" #define AUTHOR  "Kamil" #define MAX_WEAPONS 24 new const g_szMessages[MAX_WEAPONS][] {     "/ruger", "/deagle",     "/bull", "/ak",     "/m4", "/uzi",     "/socom", "/glock",     "/mossberg", "/benelli",     "/barrett", "/tmp",     "/aug", "/usas",     "/colts", "/m16",     "/mp5sd", "/mp5",     "/57", "/berettas",     "/m60", "/spas",     "/mp7", "/guns" }; new const g_iWeaponID[MAX_WEAPONS - 1] {     28, 12, 31, 13,     5, 3, 9, 22,     26, 4, 18, 17,     15, 11, 21, 27,     6, 7, 14, 8,     32, 20, 19 }; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_clcmd("say", "hook_say");     register_clcmd("say_team", "hook_say"); } public hook_say(id) {     static message[64];     read_args(message, 63);     new i;     for(i = 0; i < MAX_WEAPONS; i++) {         if(equali(message, g_szMessages[i]) && i != 23) {             ts_giveweapon(id, g_iWeaponID[i], 200, 0);             break;         }         else {             show_motd(id, "zombie_weapons.txt");             break;         }     }     return PLUGIN_HANDLED; }
But keep in mind you need to code the extra parameter because I got lazy...

stupok 10-01-2006 22:58

Re: ts_giveweapon(index,weapon,clips,extra)
 
Thanks that seems like a nice way to organize the code! It sure is a lot shorter anyways.

I have a question though. Wouldn't that code open the zombie_weapons.txt in MOTD whenever any message was sent besides something like /ruger or /deagle? That would not be any good.

Too bad you didn't have any insight into why extras may not work... My tentative theory is that the 'extras' argument must be a variable. I'm going to go ahead and test that right now.

Silver Dragon 10-02-2006 10:12

Re: ts_giveweapon(index,weapon,clips,extra)
 
Yes it is in the wrong section. Post in scripting help.

stupok 10-03-2006 00:41

Re: [solved] ts_giveweapon() 'extra' MUST be a variable
 
I really think it's worth mentioning that the 'extra' argument in ts_giveweapon(id, weapon, clips, extra) has to be a variable.

For example,
Code:
ts_giveweapon(id, 12, 200, 15)
would give a Desert Eagle without a silencer, laser, scope, or flashlight.


However,
Code:
new extras = 15 ts_giveweapon(id, 12, 200, extras)
would give a Desert Eagle with a silencer, laser, and scope (Desert Eagle cannot carry a flashlight).


All times are GMT -4. The time now is 09:43.

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