SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 27/05/2020, 09:09 PM   #1
TheOliver
Big Clucker
 
Join Date: Apr 2020
Posts: 89
Reputation: 0
Default how can i create ranges?

How can I make a rank system, for example: if I have more than 35 rank points, my rank will be bronze 1, if I have more than 70 my rank will be bronze 2.

here I leave the code that led:

Quote:
if(PlayerInflo[playerid][pRK] > 35)
{
PlayerInflo[playerid][pRango] = "Bronce 1";
}
TheOliver is offline   Reply With Quote
Old 27/05/2020, 10:00 PM   #2
Unrea1
Gangsta
 
Unrea1's Avatar
 
Join Date: Oct 2013
Location: Venezuela
Posts: 809
Reputation: 126
Default Re: how can i create ranges?

Look this example:

Quote:
Originally Posted by Logic_ View Post
This is barely a filterscript and more of a snippet; And use an array, all what you guys think is that arrays are for storing player data into the memory but you can use it for thousands of other purposes as well, same goes that thousands of you just use Streamer for objects whereas you forget the functionality it gives to make codes smaller, same goes with other plugins and tools already available..

PHP Code:
#define MAX_RANKS (3)
#define MAX_RANK_NAME (32)

enum e_RankingStructure {
        
e_RankingName[MAX_RANK_NAME],
        
e_RankingScore,
        
e_RankingColor
};

new const 
g_RankingStructure[MAX_RANKS][e_RankingStructure] {
        {
"Newbie"00xFFFFFFFF},
        {
"Wannabe"500xFF0000FF},
        {
"Scripter"1000x00FFFFFF}
};

Rank_GetPlayer(playerid) {
        
        new
                
score GetPlayerScore(playerid);

        for (new 
MAX_RANKS!= 0--) {
                if (
score >= g_RankingStructure[i][e_RankingScore])
                        return 
i;
        }

        return 
0;

PS: there might be minor mistakes in the code, written this on the browser just as an example.
You can edit this and generate a big amount of ranks.
__________________
Unrea1 is offline   Reply With Quote
Old 27/05/2020, 11:11 PM   #3
TheOliver
Big Clucker
 
Join Date: Apr 2020
Posts: 89
Reputation: 0
Default Re: how can i create ranges?

Quote:
Originally Posted by Unrea1 View Post
Look this example:



You can edit this and generate a big amount of ranks.
What if I want to put the range inside a variable to put it in a text? like this:

Quote:
format(string, sizeof(string), "Rango: %s", e_RankingName);
SendClientMessage(playerid, COLOR_BLANCO, string);
TheOliver is offline   Reply With Quote
Old 28/05/2020, 12:18 AM   #4
xRadical3
Gangsta
 
xRadical3's Avatar
 
Join Date: May 2017
Location: Iran
Posts: 558
Reputation: 20
Default Re: how can i create ranges?

Quote:
Originally Posted by TheOliver View Post
What if I want to put the range inside a variable to put it in a text? like this:
pawn Code:
format(string, sizeof(string), "Rango: %s", g_RankingStructure[ Rank_GetPlayer(playerid) ][e_RankingName]);
xRadical3 is offline   Reply With Quote
Old 28/05/2020, 12:35 AM   #5
TheOliver
Big Clucker
 
Join Date: Apr 2020
Posts: 89
Reputation: 0
Default Re: how can i create ranges?

Quote:
Originally Posted by xRadical3 View Post
pawn Code:
format(string, sizeof(string), "Rango: %s", g_RankingStructure[ Rank_GetPlayer(playerid) ][e_RankingName]);
it gives me 4 errors

Quote:
C:\Users\Locucion\Desktop\servidores de samp\competitive_dm\gamemodes\DMR.pwn(384) : error 017: undefined symbol "g_RankingStructure"
C:\Users\Locucion\Desktop\servidores de samp\competitive_dm\gamemodes\DMR.pwn(384) : error 017: undefined symbol "Rank_GetPlayer"
C:\Users\Locucion\Desktop\servidores de samp\competitive_dm\gamemodes\DMR.pwn(384) : error 029: invalid expression, assumed zero
C:\Users\Locucion\Desktop\servidores de samp\competitive_dm\gamemodes\DMR.pwn(384) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
TheOliver is offline   Reply With Quote
Old 28/05/2020, 12:42 AM   #6
xRadical3
Gangsta
 
xRadical3's Avatar
 
Join Date: May 2017
Location: Iran
Posts: 558
Reputation: 20
Default Re: how can i create ranges?

Quote:
Originally Posted by TheOliver View Post
it gives me 4 errors
Add this to your script.
PHP Code:
//by Logic_
#define MAX_RANKS (3)
#define MAX_RANK_NAME (32)

enum e_RankingStructure {
        
e_RankingName[MAX_RANK_NAME],
        
e_RankingScore,
        
e_RankingColor
};

new const 
g_RankingStructure[MAX_RANKS][e_RankingStructure] {
        {
"Newbie"00xFFFFFFFF},
        {
"Wannabe"500xFF0000FF},
        {
"Scripter"1000x00FFFFFF}
};

Rank_GetPlayer(playerid) {
        
        new
                
score GetPlayerScore(playerid);

        for (new 
MAX_RANKS!= 0--) {
                if (
score >= g_RankingStructure[i][e_RankingScore])
                        return 
i;
        }

        return 
0;

xRadical3 is offline   Reply With Quote
Old 28/05/2020, 01:28 AM   #7
TheOliver
Big Clucker
 
Join Date: Apr 2020
Posts: 89
Reputation: 0
Default Re: how can i create ranges?

Quote:
Originally Posted by xRadical3 View Post
Add this to your script.
PHP Code:
//by Logic_
#define MAX_RANKS (3)
#define MAX_RANK_NAME (32)

enum e_RankingStructure {
        
e_RankingName[MAX_RANK_NAME],
        
e_RankingScore,
        
e_RankingColor
};

new const 
g_RankingStructure[MAX_RANKS][e_RankingStructure] {
        {
"Newbie"00xFFFFFFFF},
        {
"Wannabe"500xFF0000FF},
        {
"Scripter"1000x00FFFFFF}
};

Rank_GetPlayer(playerid) {
        
        new
                
score GetPlayerScore(playerid);

        for (new 
MAX_RANKS!= 0--) {
                if (
score >= g_RankingStructure[i][e_RankingScore])
                        return 
i;
        }

        return 
0;

I already did everything and I get this

Quote:
C:\Users\Locucion\Desktop\servidores de samp\competitive_dm\gamemodes\DMR.pwn(62) : error 001: expected token: ";", but found "{"
C:\Users\Locucion\Desktop\servidores de samp\competitive_dm\gamemodes\DMR.pwn(66) : error 010: invalid function or declaration
TheOliver is offline   Reply With Quote
Old 28/05/2020, 04:14 PM   #8
TheOliver
Big Clucker
 
Join Date: Apr 2020
Posts: 89
Reputation: 0
Default Re: how can i create ranges?

Quote:
Originally Posted by TheOliver View Post
I already did everything and I get this
I NEED HELP!
TheOliver is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Porblem with ranges. AroseKhanNiazi Scripting Help 3 05/06/2017 10:56 PM
Name Tag Ranges Dex007HLH Scripting Help 2 20/02/2013 10:19 PM
GetVehicleDamageStatus value ranges? cAMo Help Archive 11 30/05/2011 03:09 PM
How to read 3 ranges from an IP? KennethRandall Help Archive 2 06/08/2010 01:19 PM
Ranges of turktelecom hipy Server Support 6 29/10/2009 04:49 AM


All times are GMT. The time now is 07:03 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.