Help ty.
#1

I start by saying that I'm learning to script and I can not understand some things like these errors, if you could explain to me how you solved this problem thank you.

Script:
PHP код:
if(dialogid == DROGA)
{
   switch(
dialogid)
   {
       case 
DIALOG_DROGA:
       {
           if(
response)
           {
                switch(
listitem)
                {
                     case 
0:
                     {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la Marijuana!");
                        
GivePlayerMoney(playerid, -1000);
                     }
                     case 
1:
                     {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la metanfetamina!");
                        
GivePlayerMoney(playerid, -1000);
                     }
                     case 
2:
                     {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la cocaina!");
                        
GivePlayerMoney(playerid, -1000);
                     }
               }
          }
       }
    }
    return 
0;

Error:
PHP код:
C:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(158) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(160) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(162) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(164) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(166) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(168) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(170) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(174) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(176) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(180) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(182) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(190) : error 010invalid function or declaration 
Reply
#2

Try this


PHP код:
if(dialogid == DROGA)
{
   switch(
dialogid)
   {
       case 
DIALOG_DROGA:
       {
           if(
response)
           {
                switch(
listitem)
                {
                     case 
0:
                     {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la Marijuana!");
                        
GivePlayerMoney(playerid, -1000);
                     }
                     case 
1:
                     {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la metanfetamina!");
                        
GivePlayerMoney(playerid, -1000);
                     }
                     case 
2:
                     {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la cocaina!");
                        
GivePlayerMoney(playerid, -1000);
                    }
                }
              }
           }
   }
    return 
1;

Reply
#3

Nope. again the errors.
Reply
#4

Quote:
Originally Posted by kevi11
Посмотреть сообщение
Nope. again the errors.
Show me the error lines.
Reply
#5

I think I was wrong to do right after another look at case.
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_ARMI:
        {
            if(
response)
            {
                switch(
listitem)
                {
                    case 
0:
                    {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato un'AK47!");
                        
GivePlayerMoney(playerid, -1000);
                        
GivePlayerWeapon(playerid30100);
                    }
                    case 
1:
                    {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato una M4!");
                        
GivePlayerMoney(playerid, -1000);
                        
GivePlayerWeapon(playerid31100);
                    }
                    case 
2:
                    {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato una desert eagle!");
                        
GivePlayerMoney(playerid, -1000);
                        
GivePlayerWeapon(playerid24100);
                    }
                }
            }
        }
    }
    return 
0;
}
if(
dialogid == DROGA)
{
   switch(
dialogid)
   {
       case 
DIALOG_DROGA:
       {
           if(
response)
           {
                switch(
listitem)
                {
                     case 
0:
                     {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la Marijuana!");
                        
GivePlayerMoney(playerid, -1000);
                     }
                     case 
1:
                     {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la metanfetamina!");
                        
GivePlayerMoney(playerid, -1000);
                     }
                     case 
2:
                     {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la cocaina!");
                        
GivePlayerMoney(playerid, -1000);
                     }
                 }
               }
            }
    }
    return 
1;

Reply
#6

This should work


PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_ARMI:
        {
            if(
response)
            {
                switch(
listitem)
                {
                    case 
0:
                    {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato un'AK47!");
                        
GivePlayerMoney(playerid, -1000);
                        
GivePlayerWeapon(playerid30100);
                    }
                    case 
1:
                    {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato una M4!");
                        
GivePlayerMoney(playerid, -1000);
                        
GivePlayerWeapon(playerid31100);
                    }
                    case 
2:
                    {
                        if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato una desert eagle!");
                        
GivePlayerMoney(playerid, -1000);
                        
GivePlayerWeapon(playerid24100);
                    }
                }
            }
        }
    }
}
case 
DIALOG_DROGA:
{
    if(
response)
    {
        switch(
listitem)
        {
            case 
0:
             {
                  if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                
SendClientMessage(playerid0xAA3333AA"Hai comprato la Marijuana!");
                  
GivePlayerMoney(playerid, -1000);
            }
             case 
1:
              {
                if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                   
SendClientMessage(playerid0xAA3333AA"Hai comprato la metanfetamina!");
                   
GivePlayerMoney(playerid, -1000);
              }
               case 
2:
            {
                   if(
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                
SendClientMessage(playerid0xAA3333AA"Hai comprato la cocaina!");
                
GivePlayerMoney(playerid, -1000);
            }
        }
    }
    return 
1;

Reply
#7

PHP код:
C:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(156) : warning 209: function "OnDialogResponse" should return a value
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(157) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(159) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(161) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(163) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(165) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(169) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(171) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(175) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(177) : error 010invalid function or declaration
C
:\Users\Eclipse\Desktop\Freeroam da 0\gamemodes\Freeroam.pwn(183) : error 010invalid function or declaration 
Reply
#8

As you can see before DROGA dialogid checking, there are extra closed brackets so it's like checking dialog and doing stuff outside of the callback.

Keep each "case X:" at the same column (2 tabs (8 spaces) right):
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch (
dialogid)
    {
        case 
DIALOG_ARMI:
        {
            if (
response)
            {
                switch (
listitem)
                {
                    case 
0:
                    {
                        if (
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato un'AK47!");
                        
GivePlayerMoney(playerid, -1000);
                        
GivePlayerWeapon(playerid30100);
                    }
                    case 
1:
                    {
                        if (
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato una M4!");
                        
GivePlayerMoney(playerid, -1000);
                        
GivePlayerWeapon(playerid31100);
                    }
                    case 
2:
                    {
                        if (
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato una desert eagle!");
                        
GivePlayerMoney(playerid, -1000);
                        
GivePlayerWeapon(playerid24100);
                    }
                }
            }
        }
        case 
DIALOG_DROGA:
        {
            if (
response)
            {
                switch (
listitem)
                {
                    case 
0:
                    {
                        if (
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la Marijuana!");
                                
GivePlayerMoney(playerid, -1000);
                    }
                    case 
1:
                    {
                        if (
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la metanfetamina!");
                        
GivePlayerMoney(playerid, -1000);
                    }
                    case 
2:
                    {
                        if (
GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid0xAA3333AA"Non hai abbastanza denaro.!");
                        
SendClientMessage(playerid0xAA3333AA"Hai comprato la cocaina!");
                        
GivePlayerMoney(playerid, -1000);
                    }
                }
            }
        }
        default: return 
0// dialogid not found, search in other scripts
    
}
    return 
1// dialogid was found

Reply
#9

Ty u so much Konstantinos, I have 1 error only.
PHP код:
error 040duplicate "case" label (value 1
Reply
#10

Konstantinos would like to understand how did you explain it to me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)