SA-MP Forums Archive
[Error with YSI\y_ini] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Error with YSI\y_ini] (/showthread.php?tid=610969)



[Error with YSI\y_ini] - Dreamwall - 30.06.2016

Hi everyone, I have a few errors with this script that I don't know how I caused them so please this is only part of my script in which I have the errors from, if the solution is because I'm missing some more codes please show me what I'm missing, heres my errors

Код:
H:\[S]uper\gamemodes\[S]uper.pwn(69) : error 055: start of function body without function header
H:\[S]uper\gamemodes\[S]uper.pwn(70) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(72) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(74) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(76) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(78) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(79) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(80) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(81) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(82) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(83) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(84) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(85) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(86) : error 010: invalid function or declaration
H:\[S]uper\gamemodes\[S]uper.pwn(87) : error 010: invalid function or declaration
Notice the errors starts in line 69 to 87, line 68 is
PHP код:
public LoadUser_data(playeridname[], value[]); 




PHP код:
forward LoadUser_data(playeridname[],value[]);
public 
LoadUser_data(playeridname[], value[]);
{
    
INI_Int("Password"shInfo[playerid][pPass]);
    
INT_Int("Cash"shInfo[playerid][pCash]);
    
INI_Int("Admin"shInfo[playerid][pAdmin]);
    
INT_Int("NormalName"shInfo[playerid][nName]);
    
INI_Int("NormalLevel"shInfo[playerid][nLevel]);
    
INT_Int("NormalSkin"shInfo[playerid][nSkin]);
    
INI_Int("NormalAbility"shInfo[playerid][nAbility]);
    
INT_Int("NormalWeakness"shInfo[playerid][nWeakness]);
    
INT_Int("SuperName"shInfo[playerid][sName]);
    
INT_Int("SuperLevel"shInfo[playerid][sLevel]);
    
INT_Int("SuperSkin"shInfo[playerid][sSkin]);
    
INT_Int("Ability_1"shInfo[playerid][sAbility1]);
    
INT_Int("Ability_2"shInfo[playerid][sAbility2]);
    
INT_Int("Ability_3"shInfo[playerid][sAbility3]);
    
INT_Int("Weakness_1"shInfo[playerid][sWeakness1]);
    
INT_Int("Weakness_2"shInfo[playerid][sWeakness2]);
    
INT_Int("Weakness_3"shInfo[playerid][sWeakness3]);
    return 
1;
}
stock UserPath(playerid)
{
    new 
string[128], pname[MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(stringsizeof(string), PATHpname);
    return 
string;
}
stock udb_hash(buf[])
{
    new 
length=strlen(buf);
    new 
s1 1;
    new 
s2 0;
    new 
n;
    for (
n=0n<lengthn++)
    {
       
s1 = (s1 buf[n]) % 65521;
       
s2 = (s2 s1)     % 65521;
    }
    return (
s2 << 16) + s1;
}
public 
OnPlayerDisconnect(playeridreason)
{
//    Cloner[playerid] = 0;
    
new INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File,"Superhuman_Roleplay");
    
INI_WriteInt(File,"Password",udb_hash(inputtext));
    
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    
INI_WriteInt(File,"Admin"SuperHuman_Info[playerid], pAdmin);
    
INI_WriteInt(File,"NormalName",GetPayerName(playerid));
    
INI_WriteInt(File,"NormalLevel"SuperHuman_Info[playerid], nLevel);
    
INI_WriteInt(File,"NormalSkin"GetPlayerSkin(playerid));
    
INI_WriteInt(File,"NormalAbility"SuperHuman_Info[playerid], nAbility);
    
INI_WriteInt(File,"NormalWeakness"SuperHuman_Info[playerid], nWeakness);
    
INI_WriteInt(File,"SuperName"SuperHuman_Info[playerid], sName);
    
INI_WriteInt(File,"SuperLevel"SuperHuman_Info[playerid], sLevel);
    
INI_WriteInt(File,"SuperSkin"SuperHuman_Info[playerid], sSkin);
    
INI_WriteInt(File,"Ability_1"SuperHuman_Info[playerid], sAbility1);
    
INI_WriteInt(File,"Ability_2"SuperHuman_Info[playerid], sAbility2);
    
INI_WriteInt(File,"Ability_3"SuperHuman_Info[playerid], sAbility3);
    
INI_WriteInt(File,"Weakness_1"SuperHuman_Info[playerid], sWeakness1);
    
INI_WriteInt(File,"Weakness_2"SuperHuman_Info[playerid], sWeakness2);
    
INI_WriteInt(File,"Weakness_3"SuperHuman_Info[playerid], sWeakness3);
    
INI_Close(File);
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialog)
    {
      case 
Dialog_Register:
      {
        if(!
response) return xxx(playeridRed"Relog and try to register next time :D"); kick(playerid);
        if(
response)
        {
          if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDialog_RegisterDIALOG_STYLE_INPUT""COL_WHITE"Registering...",""Red"You have entered an invalid password.\n"White"Type your password below to register a new account.","Register","Quit");
          new 
INI:File INI_Open(UserPath(playerid));
          
INI_SetTag(File,"Superhuman_Roleplay");
          
INI_WriteInt(File,"Password",udb_hash(inputtext));
          
INI_WriteInt(File,"Cash",0);
          
INI_WriteInt(File,"Admin","No");
          
INI_WriteInt(File,"NormalName",UsePlayerName);
          
INI_WriteInt(File,"NormalLevel",0);
          
INI_WriteInt(File,"NormalSkin",0);
          
INI_WriteInt(File,"NormalAbility","None");
          
INI_WriteInt(File,"NormalWeakness","None");
          
INI_WriteInt(File,"SuperName","None");
          
INI_WriteInt(File,"SuperLevel",0);
          
INI_WriteInt(File,"SuperSkin","None");
          
INI_WriteInt(File,"Ability_1","None");
          
INI_WriteInt(File,"Ability_2","None");
          
INI_WriteInt(File,"Ability_3","None");
          
INI_WriteInt(File,"Weakness_1","None");
          
INI_WriteInt(File,"Weakness_2","None");
          
INI_WriteInt(File,"Weakness_3","None");
          
INI_Close(File);
        }
        case 
Dialog_Login:
        {
    
            if (!
response) return kick(playerid);
            if(
response)
            {
                if(
udb_hash(inputtext) == SuperHuman_Info[playerid][pPass])
                {
                    
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
                    
GivePlayerMoney(playeridSuperHuman_Info[playerid][pCash]);
                    
ShowPlayerDialog(playeridDialog_Success_2DIALOG_STYLE_MSGBOX,""White"Success!",""Green"You have successfully logged in!","Ok","");
                }
                else
                {
                    
ShowPlayerDialog(playeridDialog_LoginDIALOG_STYLE_INPUT,""White"Login",""Red"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 
1;
            }
        }
    }
    return 
1;




Re: [Error with YSI\y_ini] - Konstantinos - 30.06.2016

Код:
public LoadUser_data(playerid, name[], value[]);
Remove that semicolon from the end.


Re: [Error with YSI\y_ini] - Dreamwall - 30.06.2016

Oh wow thank you, I never really noticed that,

oh btw I accidently added INT instead of INI.


Re: [Error with YSI\y_ini] - Dreamwall - 30.06.2016

So now these are the errors I get.

Quote:

H:\[S]uper\gamemodes\[S]uper.pwn(146) : error 017: undefined symbol "inputtext"
H:\[S]uper\gamemodes\[S]uper.pwn(148 ) : error 028: invalid subscript (not an array or too many subscripts): "SuperHuman_Info"
H:\[S]uper\gamemodes\[S]uper.pwn(148 ) : warning 215: expression has no effect
H:\[S]uper\gamemodes\[S]uper.pwn(148 ) : error 001: expected token: ";", but found "]"
H:\[S]uper\gamemodes\[S]uper.pwn(148 ) : error 029: invalid expression, assumed zero
H:\[S]uper\gamemodes\[S]uper.pwn(148 ) : fatal error 107: too many error messages on one line

And this is my code.

PHP код:
public OnPlayerDisconnect(playeridreason)
{
//    Cloner[playerid] = 0;
    
new INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File,"Superhuman_Roleplay");
    
INI_WriteInt(File,"Password",udb_hash(inputtext));
    
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    
INI_WriteInt(File,"Admin"SuperHuman_Info[playerid], pAdmin);
    
INI_WriteInt(File,"NormalName",GetPayerName(playerid));
    
INI_WriteInt(File,"NormalLevel"SuperHuman_Info[playerid], nLevel);
    
INI_WriteInt(File,"NormalSkin"GetPlayerSkin(playerid));
    
INI_WriteInt(File,"NormalAbility"SuperHuman_Info[playerid], nAbility);
    
INI_WriteInt(File,"NormalWeakness"SuperHuman_Info[playerid], nWeakness);
    
INI_WriteInt(File,"SuperName"SuperHuman_Info[playerid], sName);
    
INI_WriteInt(File,"SuperLevel"SuperHuman_Info[playerid], sLevel);
    
INI_WriteInt(File,"SuperSkin"SuperHuman_Info[playerid], sSkin);
    
INI_WriteInt(File,"Ability_1"SuperHuman_Info[playerid], sAbility1);
    
INI_WriteInt(File,"Ability_2"SuperHuman_Info[playerid], sAbility2);
    
INI_WriteInt(File,"Ability_3"SuperHuman_Info[playerid], sAbility3);
    
INI_WriteInt(File,"Weakness_1"SuperHuman_Info[playerid], sWeakness1);
    
INI_WriteInt(File,"Weakness_2"SuperHuman_Info[playerid], sWeakness2);
    
INI_WriteInt(File,"Weakness_3"SuperHuman_Info[playerid], sWeakness3);
    
INI_Close(File);
    return 
1;

Line 146 is
PHP код:
INI_WriteInt(File,"Password",udb_hash(inputtext)); 
Line 148 is
PHP код:
INI_WriteInt(File,"Admin"SuperHuman_Info[playerid], pAdmin); 
And these two lines are the two errors.


Re: [Error with YSI\y_ini] - DTV - 01.07.2016

inputtext wouldn't carry over to OnPlayerDisconnect, it should be saved in it's own variable. As for the other error, you're adding an extra parameter that the function can't detect. It's only expecting three rather than four. It's expecting it to look something like this:

pawn Код:
INI_WriteInt(File,StatName,StatValue);



Re: [Error with YSI\y_ini] - Dreamwall - 01.07.2016

Here is my Dialog Response Code.

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
  new 
hashpass[129], pname[MAX_PLAYER_NAME];
  
WP_Hash(hashpass,sizeof(hashpass),inputtext);
    
  switch(
dialog)
  {
     case 
Dialog_Register:
      {
        if(!
response) return xxx(playeridRed"Relog and try to register next time :D"); kick(playerid);
        if(
response)
          {
             if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDialog_RegisterDIALOG_STYLE_INPUT""White"Registering...",""Red"You have entered an invalid password.\n"White"Type your password below to register a new account.","Register","Quit");
             new 
INI:File INI_Open(UserPath(playerid));
             
INI_SetTag(File,"Superhuman_Roleplay");
             
INI_WriteString(file,"Password",hashpass);
             
INI_WriteInt(File,"Cash",0);
             
INI_WriteInt(File,"Admin",0);
             
INI_WriteInt(File,"NormalName",GetPlayerName(playeridpnamesizeof(pname));
             
INI_WriteInt(File,"NormalLevel",0);
             
INI_WriteInt(File,"NormalSkin",26);
             
INI_WriteInt(File,"NormalAbility","None");
             
INI_WriteInt(File,"NormalWeakness","None");
             
INI_WriteInt(File,"SuperName","None");
             
INI_WriteInt(File,"SuperLevel",0);
             
INI_WriteInt(File,"SuperSkin","None");
             
INI_WriteInt(File,"Ability_1","None");
             
INI_WriteInt(File,"Ability_2","None");
             
INI_WriteInt(File,"Ability_3","None");
             
INI_WriteInt(File,"Weakness_1","None");
             
INI_WriteInt(File,"Weakness_2","None");
             
INI_WriteInt(File,"Weakness_3","None");
             
INI_Close(File);
         }
       }
     case 
Dialog_Login:
      {
         if (!
response) return "Relog and try to login next time :D"); kick(playerid);
         if(
response)
         {
           if(!
strcmp(hashpassshInfo[playerid][pPass], false))
           {
             
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
             
GivePlayerMoney(playeridshInfo[playerid][pCash]);
             
ShowPlayerDialog(playeridDialog_Success_2DIALOG_STYLE_MSGBOX,""White"Success!",""Green"You have successfully logged in!","Ok","");
           }
           else
           {
             
ShowPlayerDialog(playeridDialog_LoginDIALOG_STYLE_INPUT,""White"Login",""Red"You have entered an incorrect password.\n"White"Type your password below to login.","Login","Quit");
           }
           return 
1;
         }
      }
   }
    return 
1;

The problem is that it causes sa-mp pawn compiler to stop working.
What causes it? I checked for brackets, can somebody else give it a try.


Re: [Error with YSI\y_ini] - DTV - 01.07.2016

INI_WriteInt is only for integers. All the variables that are suppose to save as "None" and the player name are strings, so it needs to be INI_WriteString, you also have to include the string size after "None" and the player name.

pawn Код:
INI_WriteString(File,"NormalName",GetPlayerName(playerid, pname, sizeof(pname),MAX_PLAYER_NAME);
INI_WriteString(File,"NormalAbility","None",4);
//etc.



Re: [Error with YSI\y_ini] - Dreamwall - 01.07.2016

Alright, but when I compile this part it still causes my pawn compiler library to stop working.

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
  new 
hashpass[129], pname[MAX_PLAYER_NAME];
  
WP_Hash(hashpass,sizeof(hashpass),inputtext);
    
  switch(
dialog)
  {
     case 
Dialog_Register:
      {
        if(!
response) return xxx(playeridRed"Relog and try to register next time :D"); kick(playerid);
        if(
response)
          {
             if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDialog_RegisterDIALOG_STYLE_INPUT""White"Registering...",""Red"You have entered an invalid password.\n"White"Type your password below to register a new account.","Register","Quit");
             new 
INI:File INI_Open(UserPath(playerid));
             
INI_SetTag(File,"Superhuman_Roleplay");
             
INI_WriteString(file,"Password",hashpass);
             
INI_WriteInt(File,"Cash",0);
             
INI_WriteInt(File,"Admin",0);
             
INI_WriteString(File,"NormalName",GetPlayerName(playeridnNamesizeof(nName),MAX_PLAYER_NAME);
             
INI_WriteInt(File,"NormalLevel",0128);
             
INI_WriteInt(File,"NormalSkin",26128);
             
INI_WriteString(File,"NormalAbility","None"128);
             
INI_WriteString(File,"NormalWeakness","None"128);
             
INI_WriteString(File,"SuperName","None"128);
             
INI_WriteInt(File,"SuperLevel",0);
             
INI_WriteInt(File,"SuperSkin",0);
             
INI_WriteString(File,"Ability_1","None"128);
             
INI_WriteString(File,"Ability_2","None"128);
             
INI_WriteString(File,"Ability_3","None"128);
             
INI_WriteString(File,"Weakness_1","None"128);
             
INI_WriteString(File,"Weakness_2","None"128);
             
INI_WriteString(File,"Weakness_3","None"128);
             
INI_Close(File);
         }
       }
     case 
Dialog_Login:
      {
         if (!
response) return "Relog and try to login next time :D"); kick(playerid);
         if(
response)
         {
           if(!
strcmp(hashpassshInfo[playerid][pPass], false))
           {
             
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
             
GivePlayerMoney(playeridshInfo[playerid][pCash]);
             
ShowPlayerDialog(playeridDialog_Success_2DIALOG_STYLE_MSGBOX,""White"Success!",""Green"You have successfully logged in!","Ok","");
           }
           else
           {
             
ShowPlayerDialog(playeridDialog_LoginDIALOG_STYLE_INPUT,""White"Login",""Red"You have entered an incorrect password.\n"White"Type your password below to login.","Login","Quit");
           }
           
             return 
1;
         }
      }
   }
    return 
1;

If this can't be fixed I'll post my whole script.


Re: [Error with YSI\y_ini] - Konstantinos - 01.07.2016

You shouldn't save password and other data that you know they will not change during the player's gameplay.

On another note, you had Kick function outside of the response so the player would get kicked no matter what. I changed few things:
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialog)
    {
        case 
Dialog_Register:
        {
            if(!
response) return xxx(playeridRed"Relog and try to register next time :D"), kick(playerid);
            new 
hashpass[129];
            
WP_Hash(hashpasssizeof(hashpass), inputtext);
          
            if(!
inputtext[0]) return ShowPlayerDialog(playeridDialog_RegisterDIALOG_STYLE_INPUT""White"Registering...",""Red"You have entered an invalid password.\n"White"Type your password below to register a new account.","Register","Quit"); 
            
            new 
INI:File INI_Open(UserPath(playerid)); 
            
INI_SetTag(File,"Superhuman_Roleplay"); 
            
INI_WriteString(file,"Password",hashpass); 
            
INI_WriteInt(File,"Cash",0); 
            
INI_WriteInt(File,"Admin",0); 
            
INI_WriteString(File,"NormalName",GetPlayerName(playeridnNamesizeof(nName),MAX_PLAYER_NAME); 
            
INI_WriteInt(File,"NormalLevel",0128); 
            
INI_WriteInt(File,"NormalSkin",26128); 
            
INI_WriteString(File,"NormalAbility","None"128); 
            
INI_WriteString(File,"NormalWeakness","None"128); 
            
INI_WriteString(File,"SuperName","None"128); 
            
INI_WriteInt(File,"SuperLevel",0); 
            
INI_WriteInt(File,"SuperSkin",0); 
            
INI_WriteString(File,"Ability_1","None"128); 
            
INI_WriteString(File,"Ability_2","None"128); 
            
INI_WriteString(File,"Ability_3","None"128); 
            
INI_WriteString(File,"Weakness_1","None"128); 
            
INI_WriteString(File,"Weakness_2","None"128); 
            
INI_WriteString(File,"Weakness_3","None"128); 
            
INI_Close(File); 
        }
        case 
Dialog_Login:
        {
            if(!
response) return xxx(playeridRed"Relog and try to login next time :D"), kick(playerid);
            new 
hashpass[129];
            
WP_Hash(hashpasssizeof(hashpass), inputtext);
            if(!
strcmp(hashpassshInfo[playerid][pPass], false))
            {
                
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
                
GivePlayerMoney(playeridshInfo[playerid][pCash]);
                
ShowPlayerDialog(playeridDialog_Success_2DIALOG_STYLE_MSGBOX,""White"Success!",""Green"You have successfully logged in!","Ok",""); 
            }
            else 
ShowPlayerDialog(playeridDialog_LoginDIALOG_STYLE_INPUT,""White"Login",""Red"You have entered an incorrect password.\n"White"Type your password below to login.","Login","Quit"); 
        }
        default: return 
0// dialogid not found, search in other scripts
    
}
    return 
1// dialogid was found