AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   What is wrong here??? (https://forums.alliedmods.net/showthread.php?t=3727)

joecaprini 07-12-2004 17:40

What is wrong here???
 
Yes, Im sort of new to this whole scripting thing. But, if you could, plz tell me what is wrong.

/*AMX MOD X SCRIPT
*
*AWP DOGWAR
*
*This script makes everyone use a awp and ammo
*
*Version 1.0
*
*Created by IseeOWNEDpeople AKA JoeCaprini
*/
#include <amxmodx>
#include <amxmisc>
]#include <fun>

public plugin_init(){
register_plugin("AWP DOGWAR","1.0","IseeOWNEDpeople")
register_concmd("amx_awpwar","doggystyle",ADM IN_IMMUNITY,"1 = On 2 = Off")
register_cvar("amx_awpwar","1")
register_clcmd("ammo","outofmo",-1,": Gives you more ammo")
}

public doggystyle(id){
if(get_cvar_num("amx_awpwar") == 0){
return PLUGIN_HANDLED
}

if(get_cvar_num("amx_awpwar") == 1){
new clip, ammo
new usersweapon = get_user_ammo(id,clip,ammo)

client_cmd(id, "drop")

give_item(id,weapon_awp)
give_item(id,ammo_338magnum)
give_item(id,ammo_338magnum)
give_item(id,ammo_338magnum)
}

client_print(0,print_chat,"[AWPFIGHT] AWP FIGHT IS ON")
}

public ammo(id){
new clip, ammo
new usersweapon = get_user_ammo(id,clip,ammo)

give_item(id,ammo_338magnum)
give_item(id,ammo_338magnum)
}
:cry: :cry: :cry: :cry:

FrozenWire 07-12-2004 17:44

/home/users/amxmodx/tmp/3w5n8BNF.sma(29) : warning 219: local variable "ammo" shadows a variable at a preceding level
/home/users/amxmodx/tmp/3w5n8BNF.sma(30) : warning 202: number of arguments does not match definition
/home/users/amxmodx/tmp/3w5n8BNF.sma(34) : error 017: undefined symbol "weapon_awp"
/home/users/amxmodx/tmp/3w5n8BNF.sma(35) : error 017: undefined symbol "ammo_338magnum"
/home/users/amxmodx/tmp/3w5n8BNF.sma(36) : error 017: undefined symbol "ammo_338magnum"
/home/users/amxmodx/tmp/3w5n8BNF.sma(37) : error 017: undefined symbol "ammo_338magnum"
/home/users/amxmodx/tmp/3w5n8BNF.sma(41) : warning 209: function "doggystyle" should return a value
/home/users/amxmodx/tmp/3w5n8BNF.sma(44) : warning 219: local variable "ammo" shadows a variable at a preceding level
/home/users/amxmodx/tmp/3w5n8BNF.sma(45) : warning 202: number of arguments does not match definition
/home/users/amxmodx/tmp/3w5n8BNF.sma(47) : error 017: undefined symbol "ammo_338magnum"
/home/users/amxmodx/tmp/3w5n8BNF.sma(48) : error 017: undefined symbol "ammo_338magnum"


Out of my knowledge. My guess would be check the model to make sure its correct and you incuded the a list of models but thats just my guess. Im not too sure on this.

joecaprini 07-12-2004 18:17

FIXED IT!!!
 
I had to put a return PLUGIN_HANDLED in there. 8) Now it compiled

/*AMX MOD X SCRIPT
*
*AWP DOGWAR
*
*This script makes everyone use a awp and ammo
*
*Version 1.0
*
*Created by IseeOWNEDpeople AKA JoeCaprini
*/

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

public plugin_init(){
register_plugin("AWP DOGWAR","1.0","IseeOWNEDpeople")
register_concmd("amx_awpwar","doggystyle",ADM IN_IMMUNITY,"1 = On 2 = Off")
register_cvar("amx_awpwar","1")
register_clcmd("ammo","outofmo",-1,": Gives you more ammo")
}

public doggystyle(id){
if(get_cvar_num("amx_awpwar") == 0){
return PLUGIN_HANDLED
}

if(get_cvar_num("amx_awpwar") == 1){
client_cmd(id, "drop")


give_item(id,"weapon_awp")
give_item(id,"ammo_338magnum")
give_item(id,"ammo_338magnum")
give_item(id,"ammo_338magnum")
client_print(0,print_chat,"[AWPFIGHT] AWP FIGHT IS ON")
}
return PLUGIN_HANDLED
}

public ammo(id){

give_item(id,"ammo_338magnum")
give_item(id,"ammo_338magnum")
}

kingpin 07-12-2004 18:21

please use [ small][/small ]

Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init(){ register_plugin("AWP DOGWAR","1.0","IseeOWNEDpeople") register_concmd("amx_awpwar","doggystyle",ADMIN_IMMUNITY,"1 = On 2 = Off") register_cvar("amx_awpwar","1") register_clcmd("ammo","outofmo",-1,": Gives you more ammo") } public doggystyle(id){ if(get_cvar_num("amx_awpwar") == 0){ return PLUGIN_HANDLED } if(get_cvar_num("amx_awpwar") == 1){ client_cmd(id, "drop") give_item(id,"weapon_awp") give_item(id,"ammo_338magnum") give_item(id,"ammo_338magnum") give_item(id,"ammo_338magnum") client_print(0,print_chat,"[AWPFIGHT] AWP FIGHT IS ON") } return PLUGIN_HANDLED } public ammo(id){ give_item(id,"ammo_338magnum") give_item(id,"ammo_338magnum") }

joecaprini 07-12-2004 19:08

I tried to make a batman script after this. Why doesn't it work???

Code:
/*AMX MOD X SCRIPT * *Batman Weapons * *Gives all rifles * *Version 1.1 * *Created by IseeOWNEDpeople AKA JoeCaprini */ #include <amxmodx> #include <amxmisc> #include <fun> public plugin_init(){ register_plugin("Batman Weapons","1.1","IseeOWNEDpeople") register_concmd("amx_batman","brucewayne",ADMIN_IMMUNITY,"1 = On 2 = Off") register_cvar("amx_batman","1") } public brucewayne(id){ if(get_cvar_num("amx_batman") == 0){ return PLUGIN_HANDLED } if(get_cvar_num("amx_batman") == 1){ give_item(id,"weapon_awp") give_item(id,"weapon_m4a1") give_item(id,"weapon_ak47") give_item(id,"weapon_aug") give_item(id,"weapon_sg552") give_item(id,"weapon_mp5navy") give_item(id,"weapon_xm1014") give_item(id,"weapon_elite") give_item(id,"weapon_deagle") give_item(id,"weapon_flashbang") give_item(id,"weapon_hegrenade") give_item(id,"weapon_smokegrenade") } return PLUGIN_HANDLED }

Blunted1 07-12-2004 20:55

Quote:

Originally Posted by joecaprini
I tried to make a batman script after this. Why doesn't it work???

-code-

I dunno, but if you tell me I will help you fix it :P
Obviously you must have some more information than it doesnt work.
Does it compile? Does it give you compileing errors or warnings?
Can you get it to load in game? Does it not do what you want it to? etc etc etc

[Edit] at first glance it appears that you have tried to do everything at once.
The admin requirments aren't set properly and you called the same cvar twice for the same purpose.
If you haven't already, start from the beggining and work your way up one step at a time :wink:

Code:
/*AMX MOD X SCRIPT * *Batman Weapons * *Gives all rifles * *Version 1.1 * *Created by IseeOWNEDpeople AKA JoeCaprini */ #include <amxmodx> #include <amxmisc> #include <fun> public plugin_init(){ register_plugin("Batman Weapons","1.1","IseeOWNEDpeople") register_concmd("amx_batman","brucewayne") } public brucewayne(id){ give_item(id,"weapon_awp") give_item(id,"weapon_m4a1") give_item(id,"weapon_ak47") give_item(id,"weapon_aug") give_item(id,"weapon_sg552") give_item(id,"weapon_mp5navy") give_item(id,"weapon_xm1014") give_item(id,"weapon_elite") give_item(id,"weapon_deagle") give_item(id,"weapon_flashbang") give_item(id,"weapon_hegrenade") give_item(id,"weapon_smokegrenade") }

This works.
Anyone can use it, and it is always on.
First you would need to add a cvar to turn on/off. Compile it. Test it.
Then add admin requirments. Compile it. Test it.

That way you will know what is wrong and if you cannot solve the problem you can say "I tried to add an on/off cvar and now it doesnt work when I enter the command in game" or something similar.

Blunted1 07-12-2004 21:12

Code:
/*AMX MOD X SCRIPT * *Batman Weapons * *Gives all rifles * *Version 1.1 * *Created by IseeOWNEDpeople AKA JoeCaprini */ #include <amxmodx> #include <amxmisc> #include <fun> public plugin_init(){ register_plugin("Batman Weapons","1.1","IseeOWNEDpeople") register_concmd("amx_batman","brucewayne",ADMIN_IMMUNITY,"1 = on 2 = off") register_cvar("amx_batman","1") } public brucewayne(id, level, cid){    if (!cmd_access(id,level,cid,2))       return PLUGIN_HANDLED    if (get_cvar_num("amx_batman")!=0){     give_item(id,"weapon_awp")     give_item(id,"weapon_m4a1")     give_item(id,"weapon_ak47")     give_item(id,"weapon_aug")     give_item(id,"weapon_sg552")     give_item(id,"weapon_mp5navy")     give_item(id,"weapon_xm1014")     give_item(id,"weapon_elite")     give_item(id,"weapon_deagle")     give_item(id,"weapon_flashbang")     give_item(id,"weapon_hegrenade")     give_item(id,"weapon_smokegrenade")    }    return PLUGIN_HANDLED }

There ya go, done properly.
[edit\]I should warn you though, this still will not work.
You have named the client command and the cvar as the same thing and I believe you will have to choose who you are doing this to :? [/edit]

The plugin written by you above (AWP War) will most likely be accessable by everyone and not just admins as you made the same mistake in that plugin.

If you cannot spot the difference on your own just ask and I will point it out (but give it a good decent shot, it shouldn't be too dificult)

Blunted1 07-12-2004 21:35

Here is your code completily finished for you.

Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init(){ register_plugin("Batman Weapons","1.1","IseeOWNEDpeople") register_concmd("amx_batman","admin_batman",ADMIN_IMMUNITY) register_cvar("amx_batmanon","1") } public admin_batman(id,level,cid){    if (!cmd_access(id,level,cid,2))       return PLUGIN_HANDLED    new arg[32], name2[32]    get_user_name(id,name2,31)    read_argv(1,arg,31)        if (arg[0]=='@'){       new players[32], inum       get_players(players,inum,"ae",arg[1])       if (inum==0){          console_print(id,"No clients in such team")          return PLUGIN_HANDLED       }       for(new a=0;a<inum;++a)          brucewayne(players[a])      }    else {       new player = cmd_target(id,arg,2)       if (!player) return PLUGIN_HANDLED       brucewayne(player)       new name[32]       get_user_name(player,name,31)      }    return PLUGIN_HANDLED   } public brucewayne(id){    if (get_cvar_num("amx_batmanon")!=0){     give_item(id,"weapon_awp")     give_item(id,"weapon_m4a1")     give_item(id,"weapon_ak47")     give_item(id,"weapon_aug")     give_item(id,"weapon_sg552")     give_item(id,"weapon_mp5navy")     give_item(id,"weapon_xm1014")     give_item(id,"weapon_elite")     give_item(id,"weapon_deagle")     give_item(id,"weapon_flashbang")     give_item(id,"weapon_hegrenade")     give_item(id,"weapon_smokegrenade")    }    return PLUGIN_HANDLED }

Everything works.
Command: amx_batman <authid, nick, @team or #userid>

Peli 07-12-2004 23:30

Use Small tags when you post plugin codes. :)

Blunted1 07-12-2004 23:34

Quote:

Originally Posted by kingpin
please use [ small][/small ]

It has been said, and it has been done :wink:


All times are GMT -4. The time now is 14:38.

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