Raised This Month: $ Target: $400
 0% 

Feedback request


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-04-2018 , 20:40   Re: Feedback request
Reply With Quote #4

Quote:
Originally Posted by hts View Post
Code:
case 1:
case 2:
case 3:
  return same_value_for_these;
You can't do this because in pawn you don't manually break the switch statement.

Anyhow, a few tips, if I may:

You don't want to use such a long switch with so many cases for something as simple as this. Simply create a constant array, something like this,

Code:
new const AWARD_MONEY[31] = { 0, 300, 500, 200, 100, 0, 200, 500 /* etc up to 31*/ } ;

Check https://wiki.alliedmods.net/CS_Weapons_Information on how to index the array ( 0th element shouldn't be used in this case )

Then simply
Code:
new award = AWARD_MONEY[wpn_id];
You don't need that whole function at all ( Always check if wpn_id is valid [ 1 > 30 ] so you don't run into index out of bounds errors )

Also, you don't need the num_money variable at all in this case, once you define the cur_money, work with it ( You kinda do anyway )

And the most important tip, post this kind of questions in scripting help in the future
__________________
stuff

Last edited by maqi; 07-04-2018 at 20:43.
maqi is offline
 



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 09:55.


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