SA-MP Forums Archive
Error help - 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 help (/showthread.php?tid=456029)



Error help - FireWarrior101 - 04.08.2013

pawn Код:
public OnPlayerSpawn(playerid)
{
        {
            ShowPlayerDialog(playerid, DIALOG_CLASSELECT, DIALOG_STYLE_LIST, "Class Selection", "{00C0FF}Soldier\n{00C0FF}Sniper\n{00C0FF}Engineer\n{00C0FF}JetTrooper\n{00C0FF}Pilot\n{00C0FF}Spy\n{00C0FF}Ranger\n{00C0FF}Elite Ranger", "Select", "Close");
            return 1;
        }

//==========================Rank System Implented===============================
  {
   if(GetPlayerScore(playerid) >= 0 && GetPlayerScore(playerid) < 150)  //Line 198 Unreachable Code
   {
   SendClientMessage(playerid, COLOR_CRIMSON, "You are Current a Under Trainning  Cadet and you Spawn with 75 HP ");
   SendClientMessage(playerid, COLOR_GREY, "[SERVER] {FFFFFF}Type /ranks for more information");
   }
   return 1;
  }
}
Can anyone tell me what i did wrong line 198 unreachable code


Re: Error help - CutX - 04.08.2013

the compiler wont ever reach your code at 198 because of the "{" in the line above it
also, you got quiet some useless braces in your code

try this (if that rank system thingy should also be in OnPlayerSpawn)

Код:
public OnPlayerSpawn(playerid)
{
	ShowPlayerDialog(playerid, DIALOG_CLASSELECT, DIALOG_STYLE_LIST, "Class Selection", "{00C0FF}Soldier\n{00C0FF}Sniper\n{00C0FF}Engineer\n{00C0FF}JetTrooper\n{00C0FF}Pilot\n{00C0FF}Spy\n{00C0FF}Ranger\n{00C0FF}Elite Ranger", "Select", "Close");

//==========================Rank System Implented===============================
	if(GetPlayerScore(playerid) >= 0 && GetPlayerScore(playerid) < 150)  //Line 198 Unreachable Code
	{
	SendClientMessage(playerid, COLOR_CRIMSON, "You are Current a Under Trainning  Cadet and you Spawn with 75 HP ");
	SendClientMessage(playerid, COLOR_GREY, "[SERVER] {FFFFFF}Type /ranks for more information");
	}
	return 1;
}



Re: Error help - FireWarrior101 - 04.08.2013

i dont understand i mean didnt we had to use brackets for showplayerdialog ?


Re: Error help - CutX - 04.08.2013

no it's a function
not a "if" statement for example


Re: Error help - Necip - 04.08.2013

Let me explain you in a better way. What you did is just something like this
pawn Код:
public OnPlayerSpawn(playerid)
{
    {
        ShowPlayerDialog(playerid, DIALOG_CLASSELECT, DIALOG_STYLE_LIST, "Class Selection", "{00C0FF}Soldier\n{00C0FF}Sniper\n{00C0FF}Engineer\n{00C0FF}JetTrooper\n{00C0FF}Pilot\n{00C0FF}Spy\n{00C0FF}Ranger\n{00C0FF}Elite Ranger", "Select", "Close");
    }
    return 1;
}
Which in English means something like: "On Player Spawn do do Show Player Dialog" instead of "On Player Spawn do Show Player Dialog". You can make something like this to add more brackets:
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(.....)
    {
        ShowPlayerDialog(playerid, DIALOG_CLASSELECT, DIALOG_STYLE_LIST, "Class Selection", "{00C0FF}Soldier\n{00C0FF}Sniper\n{00C0FF}Engineer\n{00C0FF}JetTrooper\n{00C0FF}Pilot\n{00C0FF}Spy\n{00C0FF}Ranger\n{00C0FF}Elite Ranger", "Select", "Close");
    }
    return 1;
}
And that's why you got errors.


Re: Error help - FireWarrior101 - 04.08.2013

public OnPlayerSpawn(playerid)
{
if(.....)
{
ShowPlayerDialog(playerid, DIALOG_CLASSELECT, DIALOG_STYLE_LIST, "Class Selection", "{00C0FF}Soldier\n{00C0FF}Sniper\n{00C0FF}Engineer \n{00C0FF}JetTrooper\n{00C0FF}Pilot\n{00C0FF}Spy\n {00C0FF}Ranger\n{00C0FF}Elite Ranger", "Select", "Close");
}
return 1;
}

what do i use for if(...)