[Help] Error in DOF2
#1

Before I would like to point out that I am learning with DOF2, I read most of the topics about it, but I still do not know how to use it perfectly, my problem is as follows.

I have a system on my server, depending on your score a specific skill is enabled, I did a check with a simple variable (ClassIde) in which I store numbers from 1 to 12, which is the amount of skills you have, then for example, such a skill can only be used if ClassId == 6, and ClassId only turns 6 when you reach 600 of score.

Basically that's it, my problem comes now, the player can only use one skill, but you can choose between them (as long as you have unlocked), so I saved the value of these varibles, with a few more strings, like the skill name in a database DOF2, so every time the player spawns, it saves the value of (ClassIde), so that when login again continue the same.

So these are the codes:

PHP код:
// Under "OnPlayerConnect" to set the saved value when connecting
    
new ClasseSystem[200], jogador[MAX_PLAYER_NAME];
    
GetPlayerName(playeridjogadorsizeof(jogador));
     
format(ClasseSystemsizeof(ClasseSystem), "CLASSES/%s.ini"jogador);
    if(
DOF2_FileExists(ClasseSystem))
    {
        
CLASSEide[playerid]     = DOF2_GetInt(ClasseSystem"ClassId");        
        
SetPlayerColor(playeridDOF2_GetString(ClasseSystem"NameColor");
        
checadorCLASSE[playerid][1] = DOF2_GetBool(ClasseSystem"Checagem1");
        
checadorCLASSE[playerid][2] = DOF2_GetBool(ClasseSystem"Checagem2");
        
checadorCLASSE[playerid][3] = DOF2_GetBool(ClasseSystem"Checagem3");
        
checadorCLASSE[playerid][4] = DOF2_GetBool(ClasseSystem"Checagem4");
        
checadorCLASSE[playerid][5] = DOF2_GetBool(ClasseSystem"Checagem5");
        
checadorCLASSE[playerid][6] = DOF2_GetBool(ClasseSystem"Checagem6");
        
checadorCLASSE[playerid][7] = DOF2_GetBool(ClasseSystem"Checagem7");
        
checadorCLASSE[playerid][8] = DOF2_GetBool(ClasseSystem"Checagem8");
        
checadorCLASSE[playerid][9] = DOF2_GetBool(ClasseSystem"Checagem9");
        
checadorCLASSE[playerid][10] = DOF2_GetBool(ClasseSystem"Checagem10");
        
checadorCLASSE[playerid][11] = DOF2_GetBool(ClasseSystem"Checagem11");
        
checadorCLASSE[playerid][12] = DOF2_GetBool(ClasseSystem"Checagem12");
    }
    else
    {
        
DOF2_CreateFile(ClasseSystem);
    } 
PHP код:
// Under "OnPlayerSpawn" to save the value in every spawn
    // This TXD is to show the skill name, who is saved in DOF2 too
    
PlayerTextDrawShow(playeridsobrevivente[playerid]);
    new 
formated[250];
    
format(formatedsizeof(formated), "%s"DOF2_GetString(ClasseSystem"RankName",);
    
PlayerTextDrawSetString(playeridsobrevivente[playerid], formated);
    if(
CLASSEide == 1)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetBool(ClasseSystem"Checagem1"checadorCLASSE[playerid][1]);
            
DOF2_SetString(ClasseSystem"RankName""Sobrevivente");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetBool(ClasseSystem"Checagem1"checadorCLASSE[playerid][1]);
            
DOF2_SetString(ClasseSystem"RankName""Sobrevivente");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    }
    if(
CLASSEide == 2)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetString(ClasseSystem"NameColor""0xFAA6FFFF");
            
DOF2_SetBool(ClasseSystem"Checagem2"checadorCLASSE[playerid][2]);
            
DOF2_SetString(ClasseSystem"RankName""Medico");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetString(ClasseSystem"NameColor""0xFAA6FFFF");
            
DOF2_SetBool(ClasseSystem"Checagem2"checadorCLASSE[playerid][2]);
            
DOF2_SetString(ClasseSystem"RankName""Medico");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    }
    if(
CLASSEide == 3)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x6DFF4CFF");
            
DOF2_SetBool(ClasseSystem"Checagem3"checadorCLASSE[playerid][3]);
            
DOF2_SetString(ClasseSystem"RankName""Engenheiro");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x6DFF4CFF");
            
DOF2_SetBool(ClasseSystem"Checagem3"checadorCLASSE[playerid][3]);
            
DOF2_SetString(ClasseSystem"RankName""Engenheiro");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    }
    if(
CLASSEide == 4)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x00EEACFF");
            
DOF2_SetBool(ClasseSystem"Checagem4"checadorCLASSE[playerid][4]);
            
DOF2_SetString(ClasseSystem"RankName""Ladrao");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x00EEACFF");
            
DOF2_SetBool(ClasseSystem"Checagem4"checadorCLASSE[playerid][4]);
            
DOF2_SetString(ClasseSystem"RankName""Ladrao");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    }
    if(
CLASSEide == 5)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetString(ClasseSystem"NameColor""0xFF0000FF");
            
DOF2_SetBool(ClasseSystem"Checagem5"checadorCLASSE[playerid][5]);
            
DOF2_SetString(ClasseSystem"RankName""Terrorista");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetString(ClasseSystem"NameColor""0xFF0000FF");
            
DOF2_SetBool(ClasseSystem"Checagem5"checadorCLASSE[playerid][5]);
            
DOF2_SetString(ClasseSystem"RankName""Terrorista");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    }
    if(
CLASSEide == 6)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x7263A5FF");
            
DOF2_SetBool(ClasseSystem"Checagem6"checadorCLASSE[playerid][6]);
            
DOF2_SetString(ClasseSystem"RankName""Pistoleiro");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x7263A5FF");
            
DOF2_SetBool(ClasseSystem"Checagem6"checadorCLASSE[playerid][6]);
            
DOF2_SetString(ClasseSystem"RankName""Pistoleiro");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    }
    if(
CLASSEide == 7)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetString(ClasseSystem"NameColor""0xFFDB00FF");
            
DOF2_SetBool(ClasseSystem"Checagem7"checadorCLASSE[playerid][7]);
            
DOF2_SetString(ClasseSystem"RankName""Mercenario");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetString(ClasseSystem"NameColor""0xFFDB00FF");
            
DOF2_SetBool(ClasseSystem"Checagem7"checadorCLASSE[playerid][7]);
            
DOF2_SetString(ClasseSystem"RankName""Mercenario");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    }
    if(
CLASSEide == 8)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x5FAAFFFF");
            
DOF2_SetBool(ClasseSystem"Checagem8"checadorCLASSE[playerid][8]);
            
DOF2_SetString(ClasseSystem"RankName""Mecanico");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x5FAAFFFF");
            
DOF2_SetBool(ClasseSystem"Checagem8"checadorCLASSE[playerid][8]);
            
DOF2_SetString(ClasseSystem"RankName""Mecanico");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    }
    if(
CLASSEide == 9)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetString(ClasseSystem"NameColor""0xFF7400FF");
            
DOF2_SetBool(ClasseSystem"Checagem9"checadorCLASSE[playerid][9]);
            
DOF2_SetString(ClasseSystem"RankName""Assassino");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetString(ClasseSystem"NameColor""0xFF7400FF");
            
DOF2_SetBool(ClasseSystem"Checagem9"checadorCLASSE[playerid][9]);
            
DOF2_SetString(ClasseSystem"RankName""Assassino");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    }
    if(
CLASSEide == 10)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x005A18FF");
            
DOF2_SetBool(ClasseSystem"Checagem20"checadorCLASSE[playerid][20]);
            
DOF2_SetString(ClasseSystem"RankName""Militar");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x005A18FF");
            
DOF2_SetBool(ClasseSystem"Checagem10"checadorCLASSE[playerid][10]);
            
DOF2_SetString(ClasseSystem"RankName""Militar");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    }
    if(
CLASSEide == 11)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x0034A3FF");
            
DOF2_SetBool(ClasseSystem"Checagem11"checadorCLASSE[playerid][11]);
            
DOF2_SetString(ClasseSystem"RankName""Cacador");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetString(ClasseSystem"NameColor""0x0034A3FF");
            
DOF2_SetBool(ClasseSystem"Checagem11"checadorCLASSE[playerid][11]);
            
DOF2_SetString(ClasseSystem"RankName""Cacador");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    }
    if(
CLASSEide == 12)
    {
        if(
DOF2_FileExists(ClasseSystem))
        {
            
DOF2_SetString(ClasseSystem"NameColor""0xA200FFFF");
            
DOF2_SetBool(ClasseSystem"Checagem12"checadorCLASSE[playerid][12]);
            
DOF2_SetString(ClasseSystem"RankName""Lendario");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        else
        {
            
DOF2_SetString(ClasseSystem"NameColor""0xA200FFFF");
            
DOF2_SetBool(ClasseSystem"Checagem12"checadorCLASSE[playerid][12]);
            
DOF2_SetString(ClasseSystem"RankName""Lendario");
            
DOF2_SetInt(ClasseSystem"ClassId"CLASSEide[playerid]);
            
DOF2_SaveFile();
        }
    } 
But I think I did it wrong, I think not, I'm sure, because by putting this, GM does not compile, it gives an error in GM's own file and followed this comes a lot of countless errors, then something is wrong, just not I know what it is, can anyone help me?

Sorry if this got a little long
Reply
#2

Hello there,

I'd like to start with some suggestions: And the first would be to use SQL, whether SQLite [I recommend if you don't wish to use UCP and doesn't require any other plugins] or MySQL, because they are languages that are used not just in SA-MP but also in other places (such as web, apps etc.)

More over, your code is not in English and I'll try my best to help you with what I could grasp. Make a chart (flow-chart) how you want something to function and then start writing a code. Furthermore, instead of checking what their class is and setting data manually - you can use arrays and loop.
Reply
#3

Quote:
Originally Posted by Logic_
Посмотреть сообщение
Hello there,

I'd like to start with some suggestions: And the first would be to use SQL, whether SQLite [I recommend if you don't wish to use UCP and doesn't require any other plugins] or MySQL, because they are languages that are used not just in SA-MP but also in other places (such as web, apps etc.)

More over, your code is not in English and I'll try my best to help you with what I could grasp. Make a chart (flow-chart) how you want something to function and then start writing a code. Furthermore, instead of checking what their class is and setting data manually - you can use arrays and loop.
I tried this but because of my knowledge of DOF2 it gets difficult, I would even change the database, however, my whole GM is already like this, I just would to know what is wrong with the code I created
Reply
#4

So ... I changed to this, I managed to compile, but now when I enter the server the server closes instantly, someone know why?

PHP код:
//Under OnPlayerConnect
    
new Archives[70], jogador[MAX_PLAYER_NAME];
    
GetPlayerName(playeridjogadorsizeof(jogador));
    
format(Archivessizeof(Archives), "Classes/%s.ini"jogador);
    if(!
fexist(Archives))
    {
        
DOF2_CreateFile(Archives);
        
DOF2_SetInt(Archives"ClasseID"1);
    }
    else
    {
        
CLASSEide[playerid] = DOF2_GetInt(Archives"ClassID");
    } 
PHP код:
// Under OnPlayerDisconnect
    
new Archives[70], jogador[MAX_PLAYER_NAME];
    
GetPlayerName(playeridjogadorsizeof(jogador));
    
format(Archivessizeof(Archives), "Classes/%s.ini"jogador);
    if(!
fexist(Archives))
    {
        
DOF2_CreateFile(Archives);
        
DOF2_SetInt(Archives"ClasseID"CLASSEide[playerid]);
        
DOF2::SaveFile();
    }
    else
    {
        
DOF2_SetInt(Archives"ClassID"CLASSEide[playerid]);
        
DOF2_SaveFile();
    }
    return 
1
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)