Help again
#1

Need help again. I think there's something wrong with my code. Please fix it for me, and tell me the things I did wrong. Thanks.

PHP код:
    if(dialogid == DIALOG_LEARN)
    {
         if(
response)
             {
                 new 
string[90];
                 if(
listitem == 0)
                {
                    if(
PlayerInfo[playerid][pLearn] > 0)
                    {
                        if(
Skills[playerid][Unarmed] < 3)
                        {
                            
PlayerInfo[playerid][pLearn] --;
                            
Skills[playerid][Unarmed] ++;
                            
format(stringsizeof(string), "SERVER: You have learned the Unarmed/Strength skill Rank %d. (/combatstyle)"Skills[playerid][Unarmed]);
                            
SendClientMessage(playerid,COLOR_WHITE,string);                        }
                        else
                        {
                            
SendClientMessage(playeridCOLOR_RED"ERROR: You cannot spend any more learning points on Unarmed/Strength skill. You have mastered it.");
                        }
                    }
                    else
                    {
                        
SendClientMessage(playeridCOLOR_RED"ERROR: You don't have any Learning Points to spend.");
                    }
                }
            else if(
listitem == 1)
            {
                if(
PlayerInfo[playerid][pLearn] > 0)
                {
                    if(
Skills[playerid][Knife] < 5)
                    {
                        
PlayerInfo[playerid][pLearn] --;
                        
Skills[playerid][Knife] ++;
                        
format(stringsizeof(string), "SERVER: You have learned the Knife skill Rank %d."Skills[playerid][Knife]
                        
SendClientMessage(playeridCOLOR_WHITE,string);
                    else
                    {
                        
SendClientMessage(playeridCOLOR_RED"ERROR: You cannot spend any more learning points on Unarmed/Strength skill. You have mastered it.");
                    }
                 }
                else
                {
                    
SendClientMessage(playeridCOLOR_RED"ERROR: You don't have any Learning Points to spend.");
                }
            }
            return 
1;
    } 
Reply
#2

I think you having errors due to missing braces and parentheses (marked edition with red)
Код:
if(dialogid == DIALOG_LEARN) 
    { 
         if(response) 
             { 
                 new string[90]; 
                 if(listitem == 0) 
                { 
                    if(PlayerInfo[playerid][pLearn] > 0) 
                    { 
                        if(Skills[playerid][Unarmed] < 3) 
                        { 
                            PlayerInfo[playerid][pLearn] --; 
                            Skills[playerid][Unarmed] ++; 
                            format(string, sizeof(string), "SERVER: You have learned the Unarmed/Strength skill Rank %d. (/combatstyle)", Skills[playerid][Unarmed]); 
                            SendClientMessage(playerid,COLOR_WHITE,string);                       
                        } 
                        else 
                        { 
                            SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot spend any more learning points on Unarmed/Strength skill. You have mastered it."); 
                        } 
                    } 
                    else 
                    { 
                        SendClientMessage(playerid, COLOR_RED, "ERROR: You don't have any Learning Points to spend."); 
                    } 
                } 
            else if(listitem == 1) 
            { 
                if(PlayerInfo[playerid][pLearn] > 0) 
                { 
                    if(Skills[playerid][Knife] < 5) 
                    { 
                        PlayerInfo[playerid][pLearn] --; 
                        Skills[playerid][Knife] ++; 
                        format(string, sizeof(string), "SERVER: You have learned the Knife skill Rank %d.", Skills[playerid][Knife]); 
                        SendClientMessage(playerid, COLOR_WHITE,string); 
                    }
                    else 
                    { 
                        SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot spend any more learning points on Unarmed/Strength skill. You have mastered it."); 
                    } 
                 } 
                else 
                { 
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You don't have any Learning Points to spend."); 
                } 
            } 
          }
            return 1; 
    }
Reply
#3

This is your code.
pawn Код:
format(string, sizeof(string), "SERVER: You have learned the Knife skill Rank %d.", Skills[playerid][Knife] SendClientMessage(playerid, COLOR_WHITE, string);
else
{
    SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot spend any more learning points on Unarmed/Strength skill. You have mastered it.");
}
You don't close the parentheses in format + the semicolon and it takes SendClientMessage function as argument. If you tried to compile it, it'd give you details errors. Afterwards, you forgot to close the bracket and basically what you are doing is this:
pawn Код:
if (..)
{
     // code..
else
{
     // code..
}
Fix the above, indent properly and make sure all the brackets (opened and closed) are equal in count.

Just a suggestion as well, use switch instead of if/else if statements for both dialogid and listitem.
Reply
#4

Didn't see that. Thanks! Is it fine to put more help here? Regarding the progress of my script.
Reply
#5

-Delete-
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)