AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How do you give weapons? (https://forums.alliedmods.net/showthread.php?t=28763)

Rolnaaba 05-22-2006 08:02

How do you give weapons?
 
I keep trying to give an AK47 using this comand
Code:
give_item(id, CSW_AK47)
but it gives me the compiler error:
Code:

Error: Expected token: ";", but found ")" on line 36
Error: Invalid expression, assumed zero on line 36
Error: Too many error messages on one line on line 36

can someone plz help me?
*NOTE* Line 36 is the line with that give_item comand on it

Stephen 05-22-2006 08:25

you should post the full source so the error could be found easier.
also it oculd mean this here

Code:
 give_item(id, CSW_AK47)

into

Code:
 give_item(id, "CSW_AK47")

Rolnaaba 05-22-2006 08:26

all the errors are found on the line I gave you and I gave you all the source code for that line...

Rolnaaba 05-22-2006 08:28

I am making a mod that give you a powered up AK here is all that I have so far:
Code:
//*****{INCLUDES}***** #include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #include <fakemeta> #include <engine> //*****{PRECATCH AK MODELS}***** public plugin_precache() {     precache_model("models/p_ak47.mdl")     precache_model("models/v_ak47.mdl")     precache_model("models/w_ak47.mdl") } //*****{PLUGIN INIT}***** public plugin_init() {     register_plugin("SilverAK", "1.0", "Rolnaaba")     register_cvar("admin_silverAK", "1")     register_cvar("admin_AKcost", "4200")     register_clcmd("/buyak", "cmd_buyak")     register_clcmd("/akprice", "func_akprice") } //*****{AK VALUE}***** new hasAK[33] //*****{BUY AK}***** public cmd_buyak(id, cid) {     new arg[32]     read_argv(1, arg, 31)     new player=cmd_target(id, arg, 2)     new id=read_data(2)     {                 hasAK[id] == 1         cs_set_user_money(id,cs_get_user_money(id)-get_cvar_num("admin_AKcost"))         give_item(id, CSW_AK47)         set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0)         show_hudmessage(id, "You have bought the Silver AK!!")         if(get_user_weapon==weapon_ak47)         {             damage = damage*4/3         }     }     return PLUGIN_HANDLED } //*****{THIS IS SUPOSED TO LOWER RECOIL}***** public client_PreThink() {     if (hasAK[id] = 1 && get_user_weapon = CSW_AK47)     {         if(get_user_button(id) & IN_ATTACK)         {             entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0});         }         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } //*****{MODEL STUFF}***** if (hasAK[id]=1 && get_user_weapon=AK47) {     entity_set_string(id, EV_SZ_viewmodel, "models/v_ak47.mdl")     entity_set_string(id, EV_SZ_weaponmodel, "models/p_ak47.mdl")     entity_set_string(id, EV_SZ_model, "models/w_ak47.mdl")     return PLUGIN_HANDLED }

Rolnaaba 05-22-2006 08:31

and while we are at it this is what all my compiler errors are god I thought was going to be a quick and easy mod!!
Code:

Welcome to the AMX Mod X 1.70-300 Compiler.
Copyright (c) 1997-2005 ITB CompuPhase, AMX Mod X Team

Warning: Expression has no effect on line 40
Error: Syntax error in the expression, or invalid function call on line 45
Error: Undefined symbol "damage" on line 47
Error: Undefined symbol "damage" on line 47
Warning: Expression has no effect on line 47
Warning: Symbol is assigned a value that is never used: "player" on line 51
Error: Undefined symbol "id" on line 55
Warning: Expression has no effect on line 55
Error: Expected token: ";", but found ")" on line 55
Error: Invalid expression, assumed zero on line 55
Error: Too many error messages on one line on line 55

Compilation aborted.
7 Errors.
Could not locate output file C:\Documents and Settings\CJ\My Documents\CJ's Documents\My Scripting\Compiled Scripts\SilverAK.amx (compile failed).

I know it couldnt find the output file because the compilation was aborted but if anyone could plz help me to fix these errors I would be eternally grateful

VEN 05-22-2006 08:32

You should pass a weapon name, not a weapon ID.
Code:
give_item(id, "weapon_ak47")

Hawk552 05-22-2006 08:34

Just read this:
http://forums.alliedmods.net/showthread.php?t=21366

The damage will require more work but it's still pretty easy.

wonsae 05-22-2006 18:52

Code:
//*****{INCLUDES}***** #include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #include <engine> //*****{PRECATCH AK MODELS}***** public plugin_precache()     {     precache_model("models/p_ak47.mdl")     precache_model("models/v_ak47.mdl")     precache_model("models/w_ak47.mdl") } //*****{PLUGIN INIT}***** public plugin_init()     {     register_plugin("SilverAK", "1.0", "Rolnaaba")     register_cvar("admin_silverAK", "1")     register_cvar("admin_AKcost", "4200")     register_clcmd("/buyak", "cmd_buyak")     register_clcmd("/akprice", "func_akprice") } //*****{AK VALUE}***** new bool:hasAK[33] //*****{BUY AK}***** public cmd_buyak(id, cid){     if(get_cvar_num("admin_silverAK") == 0){         client_print(id,print_chat,"This mod is disabled")         return PLUGIN_HANDLED     }         new arg[32], ammo, clip     read_argv(1, arg, 31)     new player = cmd_target(id, arg, 2)     id = read_data(2)     {                 hasAK[id] = true         cs_set_user_money(id,cs_get_user_money(id)-get_cvar_num("admin_AKcost"))         give_item(player, "weapon_ak47")         set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0)         show_hudmessage(id, "You have bought the Silver AK!!")         if(get_user_weapon(id,ammo,clip) == CSW_AK47)             {             // damg         }     }     return PLUGIN_HANDLED } //*****{THIS IS SUPOSED TO LOWER RECOIL}***** public client_PreThink(id){     new ammo, clip     if(hasAK[id] == true && get_user_weapon(id,ammo,clip) == CSW_AK47)         {         if(get_user_button(id) & IN_ATTACK)             {             entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0})             entity_set_string(id, EV_SZ_viewmodel, "models/v_ak47.mdl")             entity_set_string(id, EV_SZ_weaponmodel, "models/p_ak47.mdl")             entity_set_string(id, EV_SZ_model, "models/w_ak47.mdl")         }         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } public funcAKprice(id){     new price = get_cvar_num("admin_AKcost")     client_print(id,print_chat,"The Silver AK is %i",price)     return PLUGIN_HANDLED } public client_connect(id){     hasAK[id] = false } public client_disconnect(id){     hasAK[id] = false }


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

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