AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   About CSSTATS.SMA (https://forums.alliedmods.net/showthread.php?t=173082)

^SmileY 11-29-2011 19:10

About CSSTATS.SMA
 
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 :x

ConnorMcLeod 11-30-2011 01:27

Re: About CSSTATS.SMA
 
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.

jim_yang 11-30-2011 03:49

Re: About CSSTATS.SMA
 
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

^SmileY 11-30-2011 20:05

Re: About CSSTATS.SMA
 
OK, i will be try, but in another plugin this function is compiling normally.

Quote:

Originally Posted by jim_yang (Post 1605085)
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
    
}



jim_yang 11-30-2011 20:38

Re: About CSSTATS.SMA
 
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.

^SmileY 11-30-2011 22:01

Re: About CSSTATS.SMA
 
I will be try, but the method of calc skill of a player is correct applied, and using a float number?


EDIT: SOMEONE?


All times are GMT -4. The time now is 08:31.

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