Raised This Month: $ Target: $400
 0% 

switch problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shino
Senior Member
Join Date: May 2006
Old 06-05-2006 , 07:08   switch problems
Reply With Quote #1

i would like to "rename" all weapons from CSW_*** to "***"...
i was thinking of something like this:
Code:
switch(weap) {     case CSW_AK47: "ak47"     case CSW_AUG: "aug"     case CSW_AWP: "awp"     case CSW_DEAGLE: "deagle"     case CSW_ELITE: "elite"     case CSW_FAMAS: "famas"     case CSW_FIVESEVEN: "fiveseven"     case CSW_G3SG1: "g3sg1"     case CSW_GALIL: "galil"     case CSW_GLOCK18: "glock18"     case CSW_HEGRENADE: "hegrenade"     case CSW_KNIFE: "knife"     case CSW_M249: "m249"     case CSW_M3: "m3"     case CSW_M4A1: "m4a1"     case CSW_MAC10: "mac10"     case CSW_MP5NAVY: "mp5navy"     case CSW_P228: "p228"     case CSW_P90: "p90"     case CSW_SCOUT: "scout"     case CSW_SG550: "sg550"     case CSW_SG552: "sg552"     case CSW_TMP: "tmp"     case CSW_UMP45: "ump45"     case CSW_USP: "usp"     case CSW_XM1014: "xm1014" }

help, please
shino is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 06-05-2006 , 08:37  
Reply With Quote #2

What's your question?

If you're looking to use give_item, those won't work, you'll need to use weapon_<name>.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
shino
Senior Member
Join Date: May 2006
Old 06-05-2006 , 09:17  
Reply With Quote #3

sorry.

here's the code:
Code:
public plugin_init() {     register_plugin( PLUGINNAME, VERSION, AUTHOR )     register_event( "Damage", "DealDamage", "be" ); } public DealDamage(id,headshot) {     new victim, attacker, damage, weap, iweap     victim = id     attacker = get_user_attacker(victim, weap)     damage = read_data(2)     switch(iweap) {         case weap == CSW_AK47: "ak47"         case weap == CSW_AUG: "aug"         case weap == CSW_AWP: "awp"         case weap == CSW_DEAGLE: "deagle"         case weap == CSW_ELITE: "elite"         case weap == CSW_FAMAS: "famas"         case weap == CSW_FIVESEVEN: "fiveseven"         case weap == CSW_G3SG1: "g3sg1"         case weap == CSW_GALIL: "galil"         case weap == CSW_GLOCK18: "glock18"         case weap == CSW_HEGRENADE: "hegrenade"         case weap == CSW_KNIFE: "knife"         case weap == CSW_M249: "m249"         case weap == CSW_M3: "m3"         case weap == CSW_M4A1: "m4a1"         case weap == CSW_MAC10: "mac10"         case weap == CSW_MP5NAVY: "mp5navy"         case weap == CSW_P228: "p228"         case weap == CSW_P90: "p90"         case weap == CSW_SCOUT: "scout"         case weap == CSW_SG550: "sg550"         case weap == CSW_SG552: "sg552"         case weap == CSW_TMP: "tmp"         case weap == CSW_UMP45: "ump45"         case weap == CSW_USP: "usp"         case weap == CSW_XM1014: "xm1014"     }     if (weap == CSW_AK47 || weap == CSW_AUG || weap == CSW_AWP || weap == CSW_DEAGLE ||     weap == CSW_ELITE || weap == CSW_FAMAS || weap == CSW_FIVESEVEN || weap == CSW_G3SG1 ||     weap == CSW_GALIL || weap == CSW_GLOCK18 || weap == CSW_HEGRENADE || weap == CSW_KNIFE ||     weap == CSW_M249 || weap == CSW_M3 || weap == CSW_M4A1 || weap == CSW_MAC10 ||     weap == CSW_MP5NAVY || weap == CSW_P228 || weap == CSW_P90 || weap == CSW_SCOUT ||     weap == CSW_SG550 || weap == CSW_SG552 || weap == CSW_TMP || weap == CSW_UMP45 ||     weap == CSW_USP || weap == CSW_XM1014) {         if (damage > 0) {             user_silentkill(victim)                     make_deathmsg(attacker,victim,headshot,iweap)         }     } }
that's how i imagined it, but it doesn't work
shino is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 06-05-2006 , 16:12  
Reply With Quote #4

That is not how switches work. Switches are essentially a bunch of if statments.
Code:
swith(weap) {     case CSW_GLOCK18: <somthing>     case CSW_USP: <something2> }

is the same as doing

Code:
if(weap == CSW_GLOCK18)     <something> else if(weap == CSW_USP)     <something2>

But switches are faster when using a lot of cases.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 06-06-2006 , 05:09  
Reply With Quote #5

Code:
new szweap[21]; get_weaponname(attacker , szweap , 20); make_deathmsg(attacker , victim , headshot , szweap);
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Reply


Thread Tools
Display Modes

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 16:30.


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