Raised This Month: $ Target: $400
 0% 

Help with improving and optimizing code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bardukis
Member
Join Date: Jul 2014
Old 11-17-2014 , 11:56   Help with improving and optimizing code
Reply With Quote #1

Hello guys, I made for myself a code which satisfies my needs and I need your opinions, advices and recommendations to make it better in terms of scripting.
Attached Files
File Type: sma Get Plugin or Get Source (plugin.sma - 530 views - 2.7 KB)
bardukis is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 11-17-2014 , 12:07   Re: Help with improving and optimizing code
Reply With Quote #2

1.You can use offset to count spawns
2. to determine what hand use simple new hand[33]
hand[id] = 1 // lets say right hand
hand[id] = 2 // left hand
if(hand[id] == 1)
// code
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
bardukis
Member
Join Date: Jul 2014
Old 11-17-2014 , 12:17   Re: Help with improving and optimizing code
Reply With Quote #3

Quote:
Originally Posted by avril-lavigne View Post
1.You can use offset to count spawns
2. to determine what hand use simple new hand[33]
hand[id] = 1 // lets say right hand
hand[id] = 2 // left hand
if(hand[id] == 1)
// code
1. I cant understand the recommendation with offset... Can you explain me?
2. Can you explain me why? I want to learn.
bardukis is offline
Xunfop
Member
Join Date: Mar 2012
Location: 97Club
Old 11-19-2014 , 08:03   Re: Help with improving and optimizing code
Reply With Quote #4

PHP Code:
new bool:leftHand;
new 
bool:rightHand
you don't need 2 booleans, not a must b, or here will go wrong
PHP Code:
if (leftHand == true) {
    
menu_additem(menu"\dLeft Hand \r[current hand]"""0);
} else {
    
menu_additem(menu"\wLeft Hand"""0);
}
if (
rightHand == true) {
    
menu_additem(menu"\dRight Hand \r[current hand]"""0);
} else {
    
menu_additem(menu"\wRight Hand"""0);

and you should check player's hand setting instead this boolean.


PHP Code:
new firstJoin[33]; 
use boolean instead this, will more readable.
Xunfop is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 11-19-2014 , 09:08   Re: Help with improving and optimizing code
Reply With Quote #5

In fact just need this:

PHP Code:
#define MAXPLAYERS 32
new boolleftHand[MAXPLAYERS 1]

// ...

if (leftHand[id])
{
    
menu_additem(menu"\dLeft Hand \r[current hand]"""0);
    
menu_additem(menu"\wRight Hand"""0);
}

else
{
    
menu_additem(menu"\wLeft Hand"""0);
    
menu_additem(menu"\dRight Hand \r[current hand]"""0);

Edit:
About the offsets, its better way. More efficience.
__________________

Last edited by Jhob94; 11-19-2014 at 09:10.
Jhob94 is online now
bardukis
Member
Join Date: Jul 2014
Old 11-19-2014 , 13:08   Re: Help with improving and optimizing code
Reply With Quote #6

Thank you @Xunfop, Thank you Johb94.
Quote:
Originally Posted by Jhob94 View Post
About the offsets, its better way. More efficience.
Sorry but, I searched about offsets and I didnt find something... I even dont know what is offset. Can you show me?
bardukis is offline
bardukis
Member
Join Date: Jul 2014
Old 11-24-2014 , 12:37   Re: Help with improving and optimizing code
Reply With Quote #7

Can you make code better?
bardukis is offline
Old 12-05-2014, 14:47
bardukis
This message has been deleted by YamiKaitou. Reason: wait 14 days before you bump
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 17:32.


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