SA-MP Forums Archive
Pawno 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)
+--- Thread: Pawno Error (/showthread.php?tid=432305)



Pawno Error - Geeboi_Mehdi - 21.04.2013

i got this error i asked alot and i cant fix it
pawn Код:
C:\Users\Daoud\Desktop\Pilots heaven\gamemodes\PH.pwn(3978) : warning 219: local variable "ID" shadows a variable at a preceding level
C:\Users\Daoud\Desktop\Pilots heaven\gamemodes\PH.pwn(3985) : error 022: must be lvalue (non-constant)
C:\Users\Daoud\Desktop\Pilots heaven\gamemodes\PH.pwn(3985) : warning 215: expression has no effect
C:\Users\Daoud\Desktop\Pilots heaven\gamemodes\PH.pwn(3988) : warning 217: loose indentation
C:\Users\Daoud\Desktop\Pilots heaven\gamemodes\PH.pwn(3978) : warning 204: symbol is assigned a value that is never used: "ID"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
here are the lines;
pawn Код:
GetNearestCoordsForPlayer(playerid)
{
    new
    Float:DefDist = 999999999.9,
    Float:CurDist,
    ID = -1;
    for(new d; d != sizeof(ALocations); d++)
    {
        CurDist = GetPlayerDistanceFromPoint(playerid, ALocations[d][LocX], ALocations[d][LocY], ALocations[d][LocZ]);
        if(CurDist < DefDist)
        {
            DefDist = CurDist;
            ID = d;
        }
   }
   return ID;
}



Re: Pawno Error - JustinAn - 22.04.2013

Where are the specific lines?

EDIT: Like for e.g where's line 3978.


Re: Pawno Error - Geeboi_Mehdi - 22.04.2013

pawn Код:
Line 3978:      ID = -1;
Line 3985:              ID = d;
Line 3985:              ID = d;
Line 3988:  return ID;
Line 3978:  ID = -1;



Re: Pawno Error - hillko - 22.04.2013

renew a pawno


Re: Pawno Error - Geeboi_Mehdi - 22.04.2013

renew?


Re: Pawno Error - Emmet_ - 22.04.2013

Try this:

pawn Код:
stock GetNearestCoordsForPlayer(playerid)
{
    new
        Float:DefDist = 999999999.9,
        Float:CurDist,
        id = -1
    ;
    for(new d; d != sizeof(ALocations); d++)
    {
        CurDist = GetPlayerDistanceFromPoint(playerid, ALocations[d][LocX], ALocations[d][LocY], ALocations[d][LocZ]);
        if(CurDist < DefDist)
        {
            DefDist = CurDist;
            id = d;
        }
   }
   return id;
}



Re: Pawno Error - Geeboi_Mehdi - 22.04.2013

Compiled!!!! i hope it works thanks so much man what was wrong with it?


Re: Pawno Error - Emmet_ - 22.04.2013

Quote:
Originally Posted by Geeboi_Mehdi
Посмотреть сообщение
Compiled!!!! i hope it works thanks so much man what was wrong with it?
You had a variable named 'ID' defined in your script somewhere, and you tried to declare a variable with the same name inside the function.


Re: Pawno Error - Geeboi_Mehdi - 22.04.2013

Great it worked i been trying to add this for ages it works for only andro missions how can i make it work for all? do i have to copy and past the same line to under the missions here is what i have i have more but i dont want to post it all since its long
pawn Код:
stock GetNearestCoordsForPlayer(playerid)
{
    new
        Float:DefDist = 999999999.9,
        Float:CurDist,
        id = -1
    ;
    for(new d; d != sizeof(ALocations); d++)
    {
        CurDist = GetPlayerDistanceFromPoint(playerid, ALocations[d][LocX], ALocations[d][LocY], ALocations[d][LocZ]);
        if(CurDist < DefDist)
        {
            DefDist = CurDist;
            id = d;
        }
   }
    return id;
}
public StartMission(playerid)
{
    if(TypeFlight[playerid] == 1) // Andromada
    {
        new rand = GetNearestCoordsForPlayer(playerid);
        if(rand == -1) return SendClientMessage(playerid, COLOR_WHITE, "ERROR");
        new message[128];
        StartedMission[playerid] = 1;
        SetPlayerCheckpoint(playerid, ALocations[rand][LocX],ALocations[rand][LocY],ALocations[rand][LocZ], 15.0);
        strcat((FirstAPName[playerid][0]='\0',FirstAPName[playerid]),ALocations[rand][LocationName],sizeof(FirstAPName[])); //PASSWORD
        format(message,sizeof(message), "Head to {FF9900}%s {FFFFFF}and pick up the cargo goods.", ALocations[rand][LocationName]);
        SendClientMessage(playerid, COLOR_WHITE, message);
        GameTextForPlayer(playerid, "~w~Andromada ~r~Mission Started", 4000, 3);
        TypeFlight[playerid] = 1;
        MissionStage[playerid] = 1;
        WantsRecording[playerid] = 1;
        Pos1[playerid] = ALocations[rand][LocX];
        Pos2[playerid] = ALocations[rand][LocY];
        Pos3[playerid] = ALocations[rand][LocZ];
    }
    stock GetNearestCoordsForPlayer(playerid)
{
    new
        Float:DefDist = 999999999.9,
        Float:CurDist,
        id = -1
    ;
    for(new d; d != sizeof(ALocations); d++)
    {
        CurDist = GetPlayerDistanceFromPoint(playerid, ALocations[d][LocX], ALocations[d][LocY], ALocations[d][LocZ]);
        if(CurDist < DefDist)
        {
            DefDist = CurDist;
            id = d;
        }
   }
    return id;
}
    else if(TypeFlight[playerid] == 2) // AT-400
    {
        StartedMission[playerid] = 1;
        new rand = random(sizeof(ALocations));
        new string2[65], message[128];
        SetPlayerCheckpoint(playerid, ALocations[rand][LocX],ALocations[rand][LocY],ALocations[rand][LocZ], 15.0);
        format(string2, sizeof(string2), "%s", ALocations[rand][LocationName]); //PASSWORD
        strmid(FirstAPName[playerid], string2, 0, strlen(string2), 128); //PASSWORD
        //FirstAPName[playerid] = ALocations[rand][LocationName];
        //FirstAPName[playerid] = AndroDName;
        format(message,sizeof(message), "Head to {FF9900}%s {FFFFFF}and pick up the passengers.", ALocations[rand][LocationName]);
        SendClientMessage(playerid, COLOR_WHITE, message);
        GameTextForPlayer(playerid, "~w~AT-400 ~r~Mission Started", 4000, 3);
        TypeFlight[playerid] = 2;
        MissionStage[playerid] = 1;
        WantsRecording[playerid] = 1;
        Pos1[playerid] = ALocations[rand][LocX];
        Pos2[playerid] = ALocations[rand][LocY];
        Pos3[playerid] = ALocations[rand][LocZ];
    }