Raised This Month: $ Target: $400
 0% 

Giving weapons to players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BigBaller
Veteran Member
Join Date: Mar 2004
Location: Everett, WA
Old 04-28-2004 , 07:29   Giving weapons to players
Reply With Quote #1

I was in the process of updating Admin All in One commands to use weapon names instead of numbers for the weapons plugin that was included.

Well lets get down to business, the problem I am having is when I change them to weapon names, it only gives me a usp, no matter what weapon I issue a command for it gives a usp everytime.

Code:
    new usp, glock, deagle, p228, elite, fiveseven, pumpshotty, autoshotty, mp5, tmp, p90, mac10, ump45, flashbang,     ak, m4, sg552, bullup, scout, awp, sg550, g3sg1, machine_gun, kevlar, assaultsuit, grenade, smokenade, defuser //Pistols     if (weapon_give == usp){     give_item(victim_index,"weapon_usp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     }     else if (weapon_give == glock){     give_item(victim_index,"weapon_glock18")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     }     else if (weapon_give == deagle){     give_item(victim_index,"weapon_deagle")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     }

Now if I changed those names back to numbers it would like its intended to, I am confused, I tired all kinds of things and now I ask for help

Intended use is something like amx_weapon BigBaller 12 that would give me a glock under the number system that worked, with the name system it would give a usp if I used amx_weapon BigBaller glock as defined above in the code snipet.

thanks
__________________

BigBaller is offline
FlyingMongoose
Veteran Member
Join Date: Mar 2004
Old 04-28-2004 , 09:08  
Reply With Quote #2

I'm thinking removing the else statement and just making the rest their own if statements
__________________
Please do NOT PM for support.

Only ask for support in plugin threads.

TunedChaos.com - Precision Tuned Game Servers
FlyingMongoose is offline
karlos
Veteran Member
Join Date: Apr 2004
Location: Germany/Poland
Old 04-28-2004 , 09:18  
Reply With Quote #3

just a tipp:
instead of typying 8 times give_item(victim_index,"ammo_45acp")
i would prefer:
Code:
for(new a = 1; a <= 8; ++a){     give_item(victim_index,"ammo_45acp") }
source will be much smaller
karlos is offline
ts2do
Senior Member
Join Date: Mar 2004
Old 04-28-2004 , 16:18  
Reply With Quote #4

why not just give em all of the weapons
ts2do is offline
Send a message via AIM to ts2do
BAILOPAN
Join Date: Jan 2004
Old 04-28-2004 , 17:40  
Reply With Quote #5

it's a bad idea to put "new" inside a for loop. don't do it.
__________________
egg
BAILOPAN is offline
karlos
Veteran Member
Join Date: Apr 2004
Location: Germany/Poland
Old 04-28-2004 , 18:12  
Reply With Quote #6

can u tell me y?
i make it many times and had no probs
karlos is offline
FlyingMongoose
Veteran Member
Join Date: Mar 2004
Old 04-28-2004 , 18:19  
Reply With Quote #7

because it redefines the variable everytime it runs through the loop, so if you end up making an infinite loop.
__________________
Please do NOT PM for support.

Only ask for support in plugin threads.

TunedChaos.com - Precision Tuned Game Servers
FlyingMongoose is offline
BigBaller
Veteran Member
Join Date: Mar 2004
Location: Everett, WA
Old 04-28-2004 , 18:48  
Reply With Quote #8

Quote:
Originally Posted by BAILOPAN
it's a bad idea to put "new" inside a for loop. don't do it.
That can be changed easily, I also think it has to deal with the if and else if.

@Karlos, I didnt write the orignal plugin but thanks for the suggestion, less coding to worry about

@FlyingMongoose

I am not the best coder hehe, but can you show me a example of 2 diff statements that would be used in this sense, I understand you but i learn best by example. Thanks if you can
__________________

BigBaller is offline
QwertyAccess
Veteran Member
Join Date: Feb 2004
Location: Enjiru Layer
Old 04-28-2004 , 19:46  
Reply With Quote #9

could ya post da whole code :O
__________________
QwertyAccess is offline
BigBaller
Veteran Member
Join Date: Mar 2004
Location: Everett, WA
Old 04-28-2004 , 21:07  
Reply With Quote #10

OK Here is the code that I am working on.

Code:
public give_weapon(admin_index,victim_index,weapon_give) {     new arg1[32]     new usp, glock, deagle, p228, elite, fiveseven, pumpshotty, autoshotty, mp5, tmp, p90, mac10, ump45, flashbang,     ak, m4, sg552, bullup, scout, awp, sg550, g3sg1, machine_gun, kevlar, assaultsuit, grenade, smokenade, defuser     read_argv(1,arg1,32)     new team[32]     get_user_team(victim_index,team,32)     new name[32]     get_user_name(victim_index,name,32)     if (equal(arg1,"@"))     {     if (equal(team,"CT"))         {         set_hudmessage(200, 50, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)         show_hudmessage(0,"The Counter-Terrorists Have Been Given Weapons")         }         else if (equal(team,"TERRORIST"))         {         set_hudmessage(200, 50, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)         show_hudmessage(0,"The Terrorists Have Been Given Weapons")         }     }     else     {     set_hudmessage(200, 50, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)     show_hudmessage(0,"%s Has Been Given A Weapon",name)     } //Pistols     if (weapon_give == usp){     give_item(victim_index,"weapon_usp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     }     else if (weapon_give == glock){     give_item(victim_index,"weapon_glock18")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     }     else if (weapon_give == deagle){     give_item(victim_index,"weapon_deagle")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     give_item(victim_index,"ammo_50ae")     }     else if (weapon_give == p228){     give_item(victim_index,"weapon_p228")     give_item(victim_index,"ammo_357sig")     give_item(victim_index,"ammo_357sig")     give_item(victim_index,"ammo_357sig")     give_item(victim_index,"ammo_357sig")     give_item(victim_index,"ammo_357sig")     give_item(victim_index,"ammo_357sig")     }     else if (weapon_give == elite){     give_item(victim_index,"weapon_elite")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     }     else if (weapon_give == fiveseven){     give_item(victim_index,"weapon_fiveseven")     give_item(victim_index,"ammo_57mm")     give_item(victim_index,"ammo_57mm")     give_item(victim_index,"ammo_57mm")     give_item(victim_index,"ammo_57mm")     } //Primary weapons //shotguns     else if (weapon_give == pumpshotty) {     give_item(victim_index,"weapon_m3")     }     else if (weapon_give == autoshotty) {     give_item(victim_index,"weapon_xm1014")     } //Smgs     else if (weapon_give == mp5) {     give_item(victim_index,"weapon_mp5navy")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     }     else if (weapon_give == tmp) {     give_item(victim_index,"weapon_tmp")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     give_item(victim_index,"ammo_9mm")     }     else if (weapon_give == p90) {     give_item(victim_index,"weapon_p90")     give_item(victim_index,"ammo_57mm")     give_item(victim_index,"ammo_57mm")     give_item(victim_index,"ammo_57mm")     give_item(victim_index,"ammo_57mm")     }     else if (weapon_give == mac10) {     give_item(victim_index,"weapon_mac10")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     }     else if (weapon_give == ump45) {     give_item(victim_index,"weapon_ump45")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     give_item(victim_index,"ammo_45acp")     } //rifles     else if (weapon_give == ak) {     give_item(victim_index,"weapon_ak47")     give_item(victim_index,"ammo_762nato")     give_item(victim_index,"ammo_762nato")     give_item(victim_index,"ammo_762nato")     }     else if (weapon_give == sg552) {     give_item(victim_index,"weapon_sg552")     give_item(victim_index,"ammo_556nato")     give_item(victim_index,"ammo_556nato")     give_item(victim_index,"ammo_556nato")     }     else if (weapon_give == m4) {     give_item(victim_index,"weapon_m4a1")     give_item(victim_index,"ammo_556nato")     give_item(victim_index,"ammo_556nato")     give_item(victim_index,"ammo_556nato")     }     else if (weapon_give == bullup) {     give_item(victim_index,"weapon_aug")     give_item(victim_index,"ammo_556nato")     give_item(victim_index,"ammo_556nato")     give_item(victim_index,"ammo_556nato")     }     else if (weapon_give == scout) {     give_item(victim_index,"weapon_scout")     give_item(victim_index,"ammo_762nato")     give_item(victim_index,"ammo_762nato")     give_item(victim_index,"ammo_762nato")     }     else if (weapon_give == awp) {     give_item(victim_index,"weapon_awp")     give_item(victim_index,"ammo_338magnum")     give_item(victim_index,"ammo_338magnum")     give_item(victim_index,"ammo_338magnum")     }     else if (weapon_give == g3sg1) {     give_item(victim_index,"weapon_g3sg1")     give_item(victim_index,"ammo_762nato")     give_item(victim_index,"ammo_762nato")     give_item(victim_index,"ammo_762nato")     }     else if (weapon_give == sg550) {     give_item(victim_index,"weapon_sig550")     give_item(victim_index,"ammo_556nato")     give_item(victim_index,"ammo_556nato")     give_item(victim_index,"ammo_556nato")     } //machine guns     else if (weapon_give == machine_gun) {     give_item(victim_index,"weapon_m249")     give_item(victim_index,"ammo_556nato")     give_item(victim_index,"ammo_556nato")     give_item(victim_index,"ammo_556nato")     } //equipment     else if (weapon_give == kevlar) {     give_item(victim_index,"item_kevlar")     }     else if (weapon_give == assaultsuit) {     give_item(victim_index,"item_assaultsuit")     }     else if (weapon_give == flashbang) {     give_item(victim_index,"weapon_flashbang")     give_item(victim_index,"ammo_flashbang")     give_item(victim_index,"ammo_flashbang")     }     else if (weapon_give == grenade) {     give_item(victim_index,"weapon_hegrenade")     }     else if (weapon_give == smokenade) {     give_item(victim_index,"weapon_smokegrenade")     }     else if (weapon_give == defuser) {     give_item(victim_index,"item_thighpack")     }     else     {     client_print(admin_index,print_console,"[AMXX] There is no such weapon")     return PLUGIN_CONTINUE     }     client_print(admin_index,print_console,"[AMXX] Client ^"%s^" has been given weapon",name)     return PLUGIN_CONTINUE } public admin_weapon(id){     if (!(get_user_flags(id)&ADMIN_LEVEL_A)){         client_print(id,print_console,"[AMXX] You have no access to that command")         return PLUGIN_HANDLED     }     new argc = read_argc()     if (argc < 3)     {         client_print(id,print_console,"[AMXX] Usage: amx_weapon <part of nick> or <@team> <weapon to give>")         return PLUGIN_HANDLED     }     new arg1[32]     new arg2[32]     new arg3[32]     read_argv(1,arg1,32)     read_argv(2,arg2,32)     read_argv(3,arg3,32) //Team     if (equal(arg1,"@"))     {         new players[32], inum         get_players(players,inum,"e",arg2)         for(new i = 0 ;i < inum ;++i)             give_weapon(id,players[i],str_to_num(arg3))         if (inum)             client_print(id,print_console,"[AMXX] * All clients from ^"%s^" got a weapon *",arg2)         else             client_print(id,print_console,"[AMXX] No clients in such team")     } //Index     if (equal(arg1,"#"))     {         if (is_user_connected(str_to_num(arg2)))             give_weapon(id,str_to_num(arg2),str_to_num(arg3))         else             client_print(id,print_console,"[AMXX] Client not found")     } //Part of Name     else     {         new player = find_player("lb",arg1)         if (player)             give_weapon(id,player,str_to_num(arg2))         else             client_print(id,print_console,"[AMXX] Client with that part of nick not found")     }     return PLUGIN_HANDLED }

I will do the thing Karlos suggested only after I can even get the names working
__________________

BigBaller is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:33.


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