AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Client command to switch weapons? (https://forums.alliedmods.net/showthread.php?t=22013)

Jordan 12-16-2005 17:27

Client command to switch weapons?
 
Is there one? I need it :)

Or, better yet:

Can I use an array for a client cmd?

like this:

Code:
client_cmd(id, "drop", g_szPrimary)

ATM it doesn't work but I figured I did something wrong...

teame06 12-16-2005 19:51

you want them to switch weapon or drop weapons?

Jordan 12-16-2005 20:09

Well I know that
Code:
client_cmd(id, "drop")

Will drop the weapon that the player is currently holding. But, if the player is holding a m4 for example, I want him to switch his weapon to his sidearm so he can drop it.

DarlD 12-16-2005 20:18

bind "q" "lastinv"

i believe:

Code:
client_cmd(id, "lastinv")

try it out

Cheap_Suit 12-16-2005 20:37

Code:
client_cmd(id, "%s", g_szPrimary)

Code:
client_cmd(id, "slot2") client_cmd(id, "drop")

teame06 12-16-2005 20:51

@ satanwoj

What the idea of your plugin anyways? So player don't have secondary?

Cause if you run what cheapsuit said.. and for some out of the blue he doesn't have a secondary. It try to drop what ever he is holding.

Jordan 12-16-2005 21:04

Nah I'm gonna but lotsa if's in there :P

I'm making a plugin which enables players to buy guns from the other team.

Cheap_Suit 12-16-2005 21:07

Code:
#define MAX_PISTOLS 6 new g_szPistolList[MAX_PISTOLS][] =   {     "weapon_usp",     "weapon_glock",     "weapon_elites",     "weapon_fiveseven",     "weapon_p228",     "weapon_deagle" } new weapons[32], wNum get_user_weapons(id, weapons, wNum) for(new a = 0; a < wNum; a++) {     for(new i = 0; i < MAX_PISTOLS; i++) if(equali(weapons[a], g_szPistolList[i]))     {         client_cmd(id, "%s", g_szPistolList[i])         client_cmd(id, "drop")     } }

Jordan 12-16-2005 21:22

K this is where it gets weird. To start, the cs_set_user_money function doesn't work, and the weapons don't switch or drop. The weapon isn't added to the player either.

Code:
    new money = ((cs_get_user_money(id)) - dualies)     new money2 = ((cs_get_user_money(id)) - mac10)     new money3 = ((cs_get_user_money(id)) - galil)     new money4 = ((cs_get_user_money(id)) - ak47)     new money5 = ((cs_get_user_money(id)) - sg552)     new money6 = ((cs_get_user_money(id)) - g3sg1)         if (key == 0){           if(cs_get_user_money(id) < dualies){         client_print(id, print_chat, "You don't have enough money!")         return PLUGIN_HANDLED;         } else { new weapons[32], wNum   get_user_weapons(id, weapons, wNum);{   for(new a = 0; a < wNum; a++){         for(new i = 0; i < MAX_PISTOLS; i++) if(equali(weapons[a], g_szPistolList[i]))         {               client_cmd(id, "%s", g_szPistolList[i])               client_cmd(id, "drop")             give_item (id, "weapon_elite")         }         cs_set_user_money(id, money)           return PLUGIN_HANDLED         }           }         }

This is the only part of the plugin I'm actually testing atm. I have all the defines and new stuff up that the top of the plugin and it's all correct. P.S. Those final brackets really aren't where they look like.

Edit: And my whole "You don't have enough money!" things don't worik >.<

teame06 12-16-2005 22:36

Code:
{     "weapon_usp",     "weapon_glock",  // << it suppose to be weapon_glock18     "weapon_elites",     "weapon_fiveseven",     "weapon_p228",     "weapon_deagle" }


is this function a menu part of a menu?


you can change this
Code:
client_cmd(id, "%s", g_szPistolList[i])   client_cmd(id, "drop")

to
Code:
client_cmd(id, "drop %s", g_szPistolList[i])


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

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