SA-MP Forums Archive
error 017: undefined symbol "i" - 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 017: undefined symbol "i" (/showthread.php?tid=542141)



error 017: undefined symbol "i" - lulo356 - 17.10.2014

pawn Код:
C:\Users\Davey\Desktop\Divoro\gamemodes\fffff.pwn(222) : error 036: empty statement
C:\Users\Davey\Desktop\Divoro\gamemodes\fffff.pwn(228) : error 029: invalid expression, assumed zero
C:\Users\Davey\Desktop\Divoro\gamemodes\fffff.pwn(235) : error 017: undefined symbol "i"
C:\Users\Davey\Desktop\Divoro\gamemodes\fffff.pwn(237) : error 017: undefined symbol "i"
pawn Код:
public UpdateSpeed (vehid)
{
    new id = GetVehicleInfrontID (vehid);
    if (id < 0);
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        PlayerTextDrawSetString (i,RadarHud, "Speed:-");
        PlayerTextDrawSetString (i,Textdraw2,"Car Model:-");
    }
    else
    {
        new str[32], Float: velocityX, Float: velocityY, Float: velocityZ;
        GetVehicleVelocity (id, velocityX, velocityY, velocityZ);
        new speed = floatround (floatsqroot (floatpower (velocityX, 2) + floatpower (velocityY, 2) + floatpower (velocityZ, 2)) * 136.666667, floatround_round);
        for (new i = 0; i < MAX_PLAYERS; i++)
        format (str, sizeof (str), "Speed: %d", speed);
        PlayerTextDrawSetString (i,RadarHud, str);
        format (str, sizeof (str), "Car Model: %s", VehicleModel [GetVehicleModel (id) - 400]);
        PlayerTextDrawSetString (i,Textdraw2, str);
    }

    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerInVehicle (i, vehid))
        {
            PlayerTextDrawShow (i, RadarHud);
            PlayerTextDrawShow (i, Textdraw1);
            PlayerTextDrawShow (i, Textdraw2);
        }
    }
    return 1;
}
I dont know what the problem is so can you please help me?


Re: error 017: undefined symbol "i" - dominik523 - 17.10.2014

"if(id <0;" ? You can't do "if" and than ";" because it's not a command.
Код:
public UpdateSpeed (vehid)
{
    new id = GetVehicleInfrontID (vehid);
    if (id < 0)
    {
	    for (new i = 0; i < MAX_PLAYERS; i++)
	    {
	        PlayerTextDrawSetString (i,RadarHud, "Speed:-");
	        PlayerTextDrawSetString (i,Textdraw2,"Car Model:-");
	    }
	}
    else
    {
        new str[32], Float: velocityX, Float: velocityY, Float: velocityZ;
        GetVehicleVelocity (id, velocityX, velocityY, velocityZ);
        new speed = floatround (floatsqroot (floatpower (velocityX, 2) + floatpower (velocityY, 2) + floatpower (velocityZ, 2)) * 136.666667, floatround_round);
        for (new i = 0; i < MAX_PLAYERS; i++)
        format (str, sizeof (str), "Speed: %d", speed);
        PlayerTextDrawSetString (i,RadarHud, str);
        format (str, sizeof (str), "Car Model: %s", VehicleModel [GetVehicleModel (id) - 400]);
        PlayerTextDrawSetString (i,Textdraw2, str);
    }
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerInVehicle (i, vehid))
        {
            PlayerTextDrawShow (i, RadarHud);
            PlayerTextDrawShow (i, Textdraw1);
            PlayerTextDrawShow (i, Textdraw2);
        }
    }
    return 1;
}



Re: error 017: undefined symbol "i" - Rudy_ - 17.10.2014

I don't think you need to loop 2 times.... Plus i'd suggest you to break; loops after it's use is finished and Also, What lines gives the errors?


Re: error 017: undefined symbol "i" - lulo356 - 17.10.2014

Quote:
Originally Posted by Rudy_
Посмотреть сообщение
I don't think you need to loop 2 times.... Plus i'd suggest you to break; loops after it's use is finished and Also, What lines gives the errors?
pawn Код:
PlayerTextDrawSetString (i,RadarHud, str);
PlayerTextDrawSetString (i,Textdraw2, str);



Re: error 017: undefined symbol "i" - lulo356 - 17.10.2014

What do i need to do :O


Re: error 017: undefined symbol "i" - dominik523 - 17.10.2014

Have you seen what I wrote up there? Don't put ";" in the end of if statement


Re: error 017: undefined symbol "i" - lulo356 - 17.10.2014

Quote:
Originally Posted by dominik523
Посмотреть сообщение
Have you seen what I wrote up there? Don't put ";" in the end of if statement
Quote:
Originally Posted by lulo356
Посмотреть сообщение
pawn Код:
PlayerTextDrawSetString (i,RadarHud, str);
PlayerTextDrawSetString (i,Textdraw2, str);
Bro this gives the errros what do i need to do to fix that if you see in the update speed is I defined


Re: error 017: undefined symbol "i" - Rudy_ - 17.10.2014

You may edit it a bit as i don't know which loop is used for which textdraw
pawn Код:
public UpdateSpeed (vehid)
{
    new id = GetVehicleInfrontID (vehid);
    if (id < 0)
    {
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
            PlayerTextDrawSetString (i,RadarHud, "Speed:-");
            PlayerTextDrawSetString (i,Textdraw2,"Car Model:-");
        }
    }
    else
    {
        new str[32], Float: velocityX, Float: velocityY, Float: velocityZ;
        GetVehicleVelocity (id, velocityX, velocityY, velocityZ);
        new speed = floatround (floatsqroot (floatpower (velocityX, 2) + floatpower (velocityY, 2) + floatpower (velocityZ, 2)) * 136.666667, floatround_round);
        for (new r = 0; r < MAX_PLAYERS; r++)
        {
            format (str, sizeof (str), "Speed: %d", speed);
            PlayerTextDrawSetString (r,RadarHud, str);
            format (str, sizeof (str), "Car Model: %s", VehicleModel [GetVehicleModel (id) - 400]);
            PlayerTextDrawSetString (r,Textdraw2, str);
        }
    }
    for (new t = 0; t < MAX_PLAYERS; t++)
    {
        if (IsPlayerInVehicle (i, vehid))
        {
            PlayerTextDrawShow (r, RadarHud);
            PlayerTextDrawShow (t, Textdraw1);
            PlayerTextDrawShow (r, Textdraw2);
        }
    }
    return 1;
}



Re: error 017: undefined symbol "i" - lulo356 - 17.10.2014

Give me still Undefined errors

pawn Код:
C:\Users\Davey\Desktop\fffff.pwn(245) : error 017: undefined symbol "i"
C:\Users\Davey\Desktop\fffff.pwn(247) : error 017: undefined symbol "r"
C:\Users\Davey\Desktop\fffff.pwn(249) : error 017: undefined symbol "r"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.



Re: error 017: undefined symbol "i" - Rudy_ - 17.10.2014

pawn Код:
public UpdateSpeed (vehid)
{
    new id = GetVehicleInfrontID (vehid);
    if (id < 0)
    {
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
            PlayerTextDrawSetString (i,RadarHud, "Speed:-");
            PlayerTextDrawSetString (i,Textdraw2,"Car Model:-");
        }
    }
    else
    {
        new str[32], Float: velocityX, Float: velocityY, Float: velocityZ;
        GetVehicleVelocity (id, velocityX, velocityY, velocityZ);
        new speed = floatround (floatsqroot (floatpower (velocityX, 2) + floatpower (velocityY, 2) + floatpower (velocityZ, 2)) * 136.666667, floatround_round);
        for (new r = 0; r < MAX_PLAYERS; r++)
        {
            format (str, sizeof (str), "Speed: %d", speed);
            PlayerTextDrawSetString (r,RadarHud, str);
            format (str, sizeof (str), "Car Model: %s", VehicleModel [GetVehicleModel (id) - 400]);
            PlayerTextDrawSetString (r,Textdraw2, str);
        }
    }
    for (new t = 0; t < MAX_PLAYERS; t++)
    {
        if (IsPlayerInVehicle (t, vehid))
        {
            PlayerTextDrawShow (t, RadarHud);
            PlayerTextDrawShow (t, Textdraw1);
            PlayerTextDrawShow (t, Textdraw2);
        }
    }
    return 1;
}