SA-MP Forums Archive
Error - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Error (/showthread.php?tid=264282)



Error - DragonYancy - 25.06.2011

First of all than you so much about the tutorials...
But I did something false... Can you explain What is the problem?

ERROR
error 017: undefined symbol "gPlayerClass"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero[/CODE]

The error is at 3. line at here...
Код:
public OnPlayerRequestClass(playerid, classid)
{
  gPlayerClass[playerid] = classid;

  switch (classid) {

 	 		case 0:
	{
		gTeam[playerid] = TEAM_VAGOS;
		GameTextForPlayer(playerid, "~COLOR_YELLOW~TEAM_GANG", 1000, 6);
	SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
	SetPlayerFacingAngle(playerid, 270.1391);
	SetPlayerCameraPos(playerid, -2487.8013,2474.5752,20.0180);
	SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
	}
			case 1:
	{
		gTeam[playerid] = TEAM_POICE;
		GameTextForPlayer(playerid, "~COLOR_BLUE~TEAM_POLICE", 1000, 6);
	SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
	SetPlayerFacingAngle(playerid, 270.1391);
	SetPlayerCameraPos(playerid, -2478.9282,2488.5732,18.2300);
	SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
 	}
 			case 2:
	{
		gTeam[playerid] = TEAM_HITMAN;
		GameTextForPlayer(playerid, "~COLOR_BLACK~TEAM_HITMAN", 1000, 6);
	SetPlayerPos(playerid, -2625.9885,2283.4905,8.3016);
	SetPlayerFacingAngle(playerid, 272.9949);
	SetPlayerCameraPos(playerid, -2620.0159,2265.4395,8.1669);
	SetPlayerCameraLookAt(playerid, -2625.9885,2283.4905,8.3016);
	}
	return 1;
}



Re: Error - [HiC]TheKiller - 25.06.2011

At the top of your script, you must have
pawn Код:
new gPlayerClass[MAX_PLAYERS];
I think in some of the tutorials it is

pawn Код:
static gPlayerClass[MAX_PLAYERS];



Re: Error - Skaizo - 25.06.2011

add your top of script new gPlayerClass[MAX_PLAYERS];
Код:
public OnPlayerRequestClass(playerid, classid)
{
    gPlayerClass[playerid] = classid
    switch (classid) {
    case 0:
    {
	gTeam[playerid] = TEAM_VAGOS;
	GameTextForPlayer(playerid, "~COLOR_YELLOW~TEAM_GANG", 1000, 6);
	SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
	SetPlayerFacingAngle(playerid, 270.1391);
	SetPlayerCameraPos(playerid, -2487.8013,2474.5752,20.0180);
	SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
	}
	case 1:
	{
	gTeam[playerid] = TEAM_POICE;
	GameTextForPlayer(playerid, "~COLOR_BLUE~TEAM_POLICE", 1000, 6);
	SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
	SetPlayerFacingAngle(playerid, 270.1391);
	SetPlayerCameraPos(playerid, -2478.9282,2488.5732,18.2300);
	SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
 	}
 	case 2:
	{
	gTeam[playerid] = TEAM_HITMAN;
	GameTextForPlayer(playerid, "~COLOR_BLACK~TEAM_HITMAN", 1000, 6);
	SetPlayerPos(playerid, -2625.9885,2283.4905,8.3016);
	SetPlayerFacingAngle(playerid, 272.9949);
	SetPlayerCameraPos(playerid, -2620.0159,2265.4395,8.1669);
	SetPlayerCameraLookAt(playerid, -2625.9885,2283.4905,8.3016);
	}
	return 1;
}



Re: Error - DragonYancy - 25.06.2011

Thank you So much!!!


Re: Error - DragonYancy - 25.06.2011

Now problem is
only a single statement (or expression) can follow each "case"
What is it means and how can I fix it?

Код:
public OnPlayerRequestClass(playerid, classid)
{
    gPlayerClass[playerid] = classid;
    switch (classid) {
	case 1:
	{
	gTeam[playerid] = 1;
	GameTextForPlayer(playerid, "Vagos", 1000, 6);
	SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
	SetPlayerFacingAngle(playerid, 270.1391);
	SetPlayerCameraPos(playerid, -2487.8013,2474.5752,20.0180);
	SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
	}
  case 2:
	{
	gTeam[playerid] = 2;
	GameTextForPlayer(playerid, "Hitman", 1000, 6);
	SetPlayerPos(playerid, -2625.9885,2283.4905,8.3016);
	SetPlayerFacingAngle(playerid, 272.9949);
	SetPlayerCameraPos(playerid, -2620.0159,2265.4395,8.1669);
	SetPlayerCameraLookAt(playerid, -2625.9885,2283.4905,8.3016);
	}
 case 3:
	{
	gTeam[playerid] = 3;
	GameTextForPlayer(playerid, "Police", 1000, 6);
	SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
	SetPlayerFacingAngle(playerid, 270.1391);
	SetPlayerCameraPos(playerid, -2478.9282,2488.5732,18.2300);
	SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
 	}
	return 1;
}



Re: Error - legodude - 25.06.2011

put the last return under the } you have, then it'll be fixed


Re: Error - Skaizo - 25.06.2011

Код:
public OnPlayerRequestClass(playerid, classid)
{
    gPlayerClass[playerid] = classid;
    switch (classid) {
    case 1:
    {
	gTeam[playerid] = 1;
	GameTextForPlayer(playerid, "Vagos", 1000, 6);
	SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
	SetPlayerFacingAngle(playerid, 270.1391);
	SetPlayerCameraPos(playerid, -2487.8013,2474.5752,20.0180);
	SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
	}
        case 2:
	{
	gTeam[playerid] = 2;
	GameTextForPlayer(playerid, "Hitman", 1000, 6);
	SetPlayerPos(playerid, -2625.9885,2283.4905,8.3016);
	SetPlayerFacingAngle(playerid, 272.9949);
	SetPlayerCameraPos(playerid, -2620.0159,2265.4395,8.1669);
	SetPlayerCameraLookAt(playerid, -2625.9885,2283.4905,8.3016);
	}
        case 3:
	{
	gTeam[playerid] = 3;
	GameTextForPlayer(playerid, "Police", 1000, 6);
	SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
	SetPlayerFacingAngle(playerid, 270.1391);
	SetPlayerCameraPos(playerid, -2478.9282,2488.5732,18.2300);
	SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
 	}
	return 1;
}



Re: Error - DragonYancy - 25.06.2011

Quote:
Originally Posted by legodude
Посмотреть сообщение
put the last return under the } you have, then it'll be fixed
What do you mean?

Quote:
Originally Posted by Skaizo
Посмотреть сообщение
Код:
public OnPlayerRequestClass(playerid, classid)
{
    gPlayerClass[playerid] = classid;
    switch (classid) {
    case 1:
    {
	gTeam[playerid] = 1;
	GameTextForPlayer(playerid, "Vagos", 1000, 6);
	SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
	SetPlayerFacingAngle(playerid, 270.1391);
	SetPlayerCameraPos(playerid, -2487.8013,2474.5752,20.0180);
	SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
	}
        case 2:
	{
	gTeam[playerid] = 2;
	GameTextForPlayer(playerid, "Hitman", 1000, 6);
	SetPlayerPos(playerid, -2625.9885,2283.4905,8.3016);
	SetPlayerFacingAngle(playerid, 272.9949);
	SetPlayerCameraPos(playerid, -2620.0159,2265.4395,8.1669);
	SetPlayerCameraLookAt(playerid, -2625.9885,2283.4905,8.3016);
	}
        case 3:
	{
	gTeam[playerid] = 3;
	GameTextForPlayer(playerid, "Police", 1000, 6);
	SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
	SetPlayerFacingAngle(playerid, 270.1391);
	SetPlayerCameraPos(playerid, -2478.9282,2488.5732,18.2300);
	SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
 	}
	return 1;
}
Same thing happens


Re: Error - legodude - 25.06.2011

pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    gPlayerClass[playerid] = classid;
    switch (classid) {
    case 1:
    {
    gTeam[playerid] = 1;
    GameTextForPlayer(playerid, "Vagos", 1000, 6);
    SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
    SetPlayerFacingAngle(playerid, 270.1391);
    SetPlayerCameraPos(playerid, -2487.8013,2474.5752,20.0180);
    SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
    }
        case 2:
    {
    gTeam[playerid] = 2;
    GameTextForPlayer(playerid, "Hitman", 1000, 6);
    SetPlayerPos(playerid, -2625.9885,2283.4905,8.3016);
    SetPlayerFacingAngle(playerid, 272.9949);
    SetPlayerCameraPos(playerid, -2620.0159,2265.4395,8.1669);
    SetPlayerCameraLookAt(playerid, -2625.9885,2283.4905,8.3016);
    }
        case 3:
    {
    gTeam[playerid] = 3;
    GameTextForPlayer(playerid, "Police", 1000, 6);
    SetPlayerPos(playerid, -2281.2253,2288.4021,4.9645);
    SetPlayerFacingAngle(playerid, 270.1391);
    SetPlayerCameraPos(playerid, -2478.9282,2488.5732,18.2300);
    SetPlayerCameraLookAt(playerid, -2281.2253,2288.4021,4.9645);
    }
}
return 1;



Re: Error - DragonYancy - 25.06.2011

Now I have these...

warning 225: unreachable code
error 029: invalid expression, assumed zero
error 004: function "OnPlayerConnect" is not implemented
warning 225: unreachable code
error 029: invalid expression, assumed zero
error 004: function "OnPlayerDisconnect" is not implemented
error 030: compound statement not closed at the end of file