Pawno Error
#1

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;
}
Reply
#2

Where are the specific lines?

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

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

renew a pawno
Reply
#5

renew?
Reply
#6

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;
}
Reply
#7

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

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.
Reply
#9

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];
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)