Raised This Month: $ Target: $400
 0% 

About CSSTATS.SMA


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 11-29-2011 , 19:10   About CSSTATS.SMA
Reply With Quote #1

I used a new method to calc a Rank: Based on Skill..


but whats wrong with this simple function:

PHP Code:
#include <amxmodx>

#pragma semicolon 1

new Float:Weight;

public 
get_score(Stats[11], Body[8])
{
    new 
Float:fStats[8];
    
    for(new 
08i++) fStats[i] = float(Stats[i]);
    
    if(
fStats[0] > && fStats[0] <= 25Weight 5.0;
    
    else if(
fStats[0] > 25 && fStats[0] <= 50Weight 15.0;
        
    else if(
fStats[0] > 50 && fStats[0] <= 100Weight 20.0;
        
    else if(
fStats[0] > 100 && fStats[0] <= 250Weight 35.0;
        
    else if(
fStats[0] > 250 && fStats[0] <= 500Weight 50.0;
        
    else if(
fStats[0] > 500 && fStats[0] <= 750Weight 75.0;
        
    else if(
fStats[0] > 750 && fStats[0] <= 1000Weight 90.0;
        
    else if(
fStats[0] > 1000Weight 100.0;
        
    return ((
fStats[0] / fStats[0] + fStats[1]) + (fStats[5] / fStats[4]) + (fStats[2] / fStats[0])) * Weight;

Code:
//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// csstats.sma
// C:\Documents and Settings\Administrator\Desktop\SC\csstats.sma(29) : warning
213: tag mismatch
// Header size:            172 bytes
// Code size:             2240 bytes
// Data size:                4 bytes
// Stack/heap size:      16384 bytes; estimated max. usage=41 cells (164 bytes)
// Total requirements:   18800 bytes
//
// 1 Warning.
// Done.
//
// Compilation Time: 0,2 sec
// ----------------------------------------

Press enter to exit ...
EDIT:
Sorry for code, i need to use switch() in whole function, but dont works again
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 11-29-2011 at 19:11. Reason: Sorry for code, i need to use switch() in whole function, but dont works again :x
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-30-2011 , 01:27   Re: About CSSTATS.SMA
Reply With Quote #2

You declare the function as integer (implied when no tag) and you try to return a float.

Either you declare it like that :

public Float:get_score(Stats[11], Body[8])

or you need to round the return result.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-30-2011 , 03:49   Re: About CSSTATS.SMA
Reply With Quote #3

plus, switch() only support integar matching, and you should manage your if-else if statement like this
if( x > 1000 )
else if( x > 750 )
else if( x > 500 )
...
else if( x > 0 )
else
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 11-30-2011 , 20:05   Re: About CSSTATS.SMA
Reply With Quote #4

OK, i will be try, but in another plugin this function is compiling normally.

Quote:
Originally Posted by jim_yang View Post
plus, switch() only support integar matching, and you should manage your if-else if statement like this
if( x > 1000 )
else if( x > 750 )
else if( x > 500 )
...
else if( x > 0 )
else
PHP Code:
switch(Value)
{
    case 
10 .. 20:
    {
        
result
    
}

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 11-30-2011 at 20:11. Reason: Ops.....
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-30-2011 , 20:38   Re: About CSSTATS.SMA
Reply With Quote #5

switch is not a proper choice when you deal with large scale.
the only benefit is just make your code so-called clear but not that efficient you think.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 11-30-2011 , 22:01   Re: About CSSTATS.SMA
Reply With Quote #6

I will be try, but the method of calc skill of a player is correct applied, and using a float number?


EDIT: SOMEONE?
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 12-01-2011 at 23:18.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Old 12-05-2011, 15:56
^SmileY
This message has been deleted by ConnorMcLeod. Reason: up within 15 days
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 08:31.


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