SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 06/12/2009, 07:19 PM   #1
Michelman
Little Clucker
 
Join Date: Dec 2009
Posts: 2
Reputation: 0
Default [HELP]Unreachable code

Hi Guys, This is my first post and I came here because I have an problem,

I use this code
Code:
public OnPlayerConnect(playerid)
{
  new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(string, sizeof(string), "%s has joined the server", pname);
  SendClientMessageToAll(0xAAAAAAAA, string);
  return 1;

  SendClientMessage(playerid, COLOR_GREEN, "Welcome to Michel's server, Enjoy your stay !");
  return 1;
}
But I get this error:
D:\GTA San-Andreas\Server\pawno\First script.pwn(473) : warning 225: unreachable code

SendClientMessage(playerid, COLOR_GREEN, "Welcome to Michel's server, Enjoy your stay !"); is the 473 line

Michelman is offline  
Old 06/12/2009, 07:22 PM   #2
Remi-X
Huge Clucker
 
Join Date: Dec 2008
Posts: 296
Reputation: 0
Default Re: [HELP]Unreachable code

return means that your callback will be ended.
Code:
public OnPlayerConnect(playerid)
{
  new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(string, sizeof(string), "%s has joined the server", pname);
  SendClientMessageToAll(0xAAAAAAAA, string);
  return 1; //So here your script ends. (Solution is to remove this line)
  //And it wont reach this, but you have code below this.
  SendClientMessage(playerid, COLOR_GREEN, "Welcome to Michel's server, Enjoy your stay !"); 
  return 1;
}
Remi-X is offline  
Old 06/12/2009, 07:23 PM   #3
[XST]O_x
High-roller
 
[XST]O_x's Avatar
 
Join Date: Aug 2009
Posts: 1,962
Reputation: 94
Default Re: [HELP]Unreachable code

pawn Code:
public OnPlayerConnect(playerid)
{
  new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(string, sizeof(string), "%s has joined the server", pname);
  SendClientMessageToAll(0xAAAAAAAA, string);
  SendClientMessage(playerid, COLOR_GREEN, "Welcome to Michel's server, Enjoy your stay !");
  return 1;
}
You've putted two 'return 1;' .

[XST]O_x is offline  
Old 06/12/2009, 07:25 PM   #4
Michelman
Little Clucker
 
Join Date: Dec 2009
Posts: 2
Reputation: 0
Default Re: [HELP]Unreachable code

My bad, Thanks for the help
Michelman is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help With this Unreachable Code ihatetn931 Help Archive 6 06/01/2010 01:15 PM
How is this an unreachable code?? Globe2009 Help Archive 4 10/11/2009 12:27 AM
[Help] Unreachable Code cozza123456 Help Archive 4 14/08/2009 02:36 PM
Unreachable code Rhemsis Help Archive 2 24/06/2009 09:12 PM


All times are GMT. The time now is 11:51 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.