Unreachable Code
#1

Quote:

public OnPlayerConnect(playerid)
{
new Spieler[64];
new Sname[MAX_PLAYER_NAME];
GetPlayerName(playerid,Sname,sizeof(Sname));
format(Spieler,sizeof(Spieler),"/Spieler/%s.txt",Sname);
if(dini_Exists(Spieler))
{
SendClientMessage(playerid,0xFFAA00FF,"[Server]: Welcome back");
ShowPlayerDialog(playerid,LOGIN,DIALOG_STYLE_PASSW ORD,"Login","Your Account was found. Login.","Login","Cancel");
return 1;
}
else
{
SendClientMessage(playerid,0x00B9FFFF,"Welcome to "ClanTag" DEATHMATCH /killme to Respawn!");
ShowPlayerDialog(playerid,REGISTER,DIALOG_STYLE_IN PUT,"Register","Choose a Password to register","Register","Cancel");
return 1;
}
if(sSpieler[playerid][Deaktiviert] == 1)
{
Kick(playerid);
return 1;
}
return 1;
}


// "Deaktiviert" is like "banned". Its for a command where you can deactivate Accounts per Admin Command

The Player must be kicked if "Deaktivieren is 1 (YES)"


" warning 225: unreachable code" > Please help me Fix that
Reply
#2

There are many threads about this. A simple search could have returned a lot of topics about this. Here's one.
On my phone so I can't sort the code lol.

forum.sa-mp.com/showthread.php?t=133238
Reply
#3

I read this too, but It didnt help me, can you do this for me, short pls ? ^^
Reply
#4

need help
Reply
#5

Read your code carefully. The code "translated" in english: If the file exists do ___ and end the function returning 1, else do ___ and end the function. If sSpelier[playerid][Deaktiviert] is equal to 1, kick playerid and end the function. End the function and return 1.
As you can see, for the compiler the code was ended in the first sentence. And then it was ended again when it was checking for Deaktiviert. And ended again.
Rearanged the code and solved it:
PHP код:
public OnPlayerConnect(playerid)
{
new 
Spieler[64];
new 
Sname[MAX_PLAYER_NAME];
GetPlayerName(playerid,Sname,sizeof(Sname));
format(Spieler,sizeof(Spieler),"/Spieler/%s.txt",Sname);
if(
sSpieler[playerid][Deaktiviert] == 1//check it. (just to make sure you don't show the dialog when he is Deaktiviert)
{
Kick(playerid);
return 
1;
}
if(
dini_Exists(Spieler))
{
SendClientMessage(playerid,0xFFAA00FF,"[Server]: Welcome back");
ShowPlayerDialog(playerid,LOGIN,DIALOG_STYLE_PASSW ORD,"Login","Your Account was found. Login.","Login","Cancel");
return 
1;
}
SendClientMessage(playerid,0x00B9FFFF,"Welcome to "ClanTag" DEATHMATCH /killme to Respawn!");
ShowPlayerDialog(playerid,REGISTER,DIALOG_STYLE_IN PUT,"Register","Choose a Password to register","Register","Cancel");
return 
1;

PS: Hope you understand me.
PS2: This is the way I make commands: condition, sscanf no parameter part, actual command. It also applies here.
Reply
#6

Hey, thank you very much! Got it, there is no Warning anymore.

But when the Player goes on the server (if he is deaktiviert) then he will not be kicked or something

Sry for my noob scripting, but I 'm a beginner^^

Here is my Stock:


Quote:

stock IstSpielerDeaktiviert(playerid)
{
if(sSpieler[playerid][Deaktiviert] == 1)
SendClientMessage(playerid,COLOR_RED,"Youre deactivatet!");
return 1;
}

My Enum
Quote:

enum SpielerDaten
{
Adminlevel,
Level,
Fraktion,
Team,
sLogin,
Deaktiviert
};



// I registered "Deaktiviert" in all "Dini_set" files so its saved
Reply
#7

Oh, my bad, sorry. I didn't realise that it need to be loaded before from the file.
It will look like this now: (complete the dini part)
PHP код:
public OnPlayerConnect(playerid)
{
new 
Spieler[64];
new 
Sname[MAX_PLAYER_NAME];
GetPlayerName(playerid,Sname,sizeof(Sname));
format(Spieler,sizeof(Spieler),"/Spieler/%s.txt",Sname);
if(
sSpieler[playerid][Deaktiviert] == 1//check it. (just to make sure you don't show the dialog when he is Deaktiviert)
{
Kick(playerid);
return 
1;
}
if(
dini_Exists(Spieler))
{
new 
deaktiviert // <--- Here you get it from the file.
if(deaktiviert == 1)
{
Kick(playerid);
return 
1;
}
SendClientMessage(playerid,0xFFAA00FF,"[Server]: Welcome back");
ShowPlayerDialog(playerid,LOGIN,DIALOG_STYLE_PASSW ORD,"Login","Your Account was found. Login.","Login","Cancel");
return 
1;
}
SendClientMessage(playerid,0x00B9FFFF,"Welcome to "ClanTag" DEATHMATCH /killme to Respawn!");
ShowPlayerDialog(playerid,REGISTER,DIALOG_STYLE_IN PUT,"Register","Choose a Password to register","Register","Cancel");
return 
1
PS: Complete the dini part (I haven't used dini /y_ini or any other file saving, just MySQL (it is simpler from my perspective), so I can't complete it).
Reply
#8

Thx, but there is another problem -__-

(135) : error 001: expected token: ";", but found "if
Reply
#9

Can you just tell me what is the name of the saving stuff inside the file, you saving it?
PS: Sorry for my bad English, but I can help you!
Reply
#10

Quote:
Originally Posted by Kraeror
Посмотреть сообщение
Can you just tell me what is the name of the saving stuff inside the file, you saving it?
PS: Sorry for my bad English, but I can help you!
Код:
stock SpielerSpeichern(playerid)          //This is for Saving
{
	new Spieler[64];
	new Sname[MAX_PLAYER_NAME];
	GetPlayerName(playerid,Sname,sizeof(Sname));
	format(Spieler,sizeof(Spieler),"/Spieler/%s.txt",Sname);
	if(dini_Exists(Spieler))
	{
		dini_IntSet(Spieler,"Adminlevel",sSpieler[playerid][Adminlevel]);
		dini_IntSet(Spieler,"Level",sSpieler[playerid][Level]);
		dini_IntSet(Spieler,"Fraktion",sSpieler[playerid][Fraktion]);
		dini_IntSet(Spieler,"Team",sSpieler[playerid][Team]);
		dini_IntSet(Spieler,"Deaktiviert",sSpieler[playerid][Deaktiviert]);
	}
	return 1;
}

Spieler = "Player" Fraktion = "Fraction / Team"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)