Car park zone help
#1

Trying to make carpark zones so players can park in public parking areas but when i make the array for it i come up with 4 codes and i believe i did everything right....
Код:
error 008: must be a constant expression; assumed zero   this one 3 times
pawn Код:
new Float:CarParkX [1] =
{
    {-2409.8438},//this line
    {-2412.1250}
};

new Float:CarParkY [1] =
{
    {1544.9453},//this line
    {1544.9453}
};

new Float:CarParkZ [1] =
{
    {7.0000},//this line
    {17.0469}
};
And this is the code line for what tha array is for and the other code i get......
Код:
: error 017: undefined symbol "CarParkX"
this is the pawn...
pawn Код:
if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ])||(IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX, CarParkY, CarParkZ)))
I know i am prolly doing it the wrong way. Everything looks correct, just need a little assistance on it to find my problem and mabye a easyer way.

Thanks
Nick
Reply
#2

well your arrays are defined wrong.

ill show you with one of them

pawn Код:
new Float:CarParkZ [1] =
{
    {7.0000},//this line
    {17.0469}
};
you have a 2d array but write it as a 1d array

so you only need a single array


pawn Код:
new Float:CarParkZ [2] =
{
    7.0000,
    17.0469
};
also note i changed the new Float:CarParkZ [1] to new Float:CarParkZ [2]

this is because there are 2 cells in your array not 1,


now
cell 1 = CarParkZ [0]
cell 2 = CarParkZ [1]


I hope this clears things up a bit.
Reply
#3

pawn Код:
new Float:CarParkX [1] [2]=
{
    {-2409.8438},//this line
    {-2412.1250}
};

new Float:CarParkY [1][2] =
{
    {1544.9453},//this line
    {1544.9453}
};

new Float:CarParkZ [1][2] =
{
    {7.0000},//this line
    {17.0469}
};
pawn Код:
new /* variable name */ [ /* array*/] [ /* cells */];
Reply
#4

Well i used your guys suggestions and changed it up and ended up making it like this...
pawn Код:
new Float:CarParkX [2] = {
-2409.8438,
-2412.1250
};

new Float:CarParkY [2] = {
1544.9453,
1544.9453
};

new Float:CarParkZ [2] = {
7.0000,
17.0469
};
All the codes are gone excpet this one...
Код:
error 017: undefined symbol "CarParkX"
for this line....
pawn Код:
if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ])||(IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX, CarParkY, CarParkZ)))
Any suggestions on that?
Reply
#5

Quote:
Originally Posted by DarkScripter
Посмотреть сообщение
pawn Код:
new Float:CarParkX [1] [2]=
{
    {-2409.8438},//this line
    {-2412.1250}
};

new Float:CarParkY [1][2] =
{
    {1544.9453},//this line
    {1544.9453}
};

new Float:CarParkZ [1][2] =
{
    {7.0000},//this line
    {17.0469}
};
pawn Код:
new /* variable name */ [ /* array*/] [ /* cells */];
whats the point of this? he dont need the array to be that big with that many dimensions.




on to the problem


make sure the CaParkX , Y , Z defines are before that line of code.

place them near the top of you file.

also youll need to add what cell your using

like CarParkX[0] or CarParkX[1]


heres the completed code

pawn Код:
if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ])||(IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[0], CarParkY[0], CarParkZ[0])) || (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[1], CarParkY[1], CarParkZ[1])))
i think thats what ya looking for,


regards,
Reply
#6

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
whats the point of this? he dont need the array to be that big with that many dimensions.




on to the problem


make sure the CaParkX , Y , Z defines are before that line of code.

place them near the top of you file.

also youll need to add what cell your using

like CarParkX[0] or CarParkX[1]


heres the completed code

pawn Код:
if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ])||(IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[0], CarParkY[0], CarParkZ[0])) || (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[1], CarParkY[1], CarParkZ[1])))
i think thats what ya looking for,


regards,
Thanks it works flawlessy!!!

but how you have it CarParkX[0], CarParkX[1] and so on is there a easyer way so when i add more carparks i just have to add them to the array and not that line too? is is that the only way i can do that? at the moment them are just dummy locations to test.


Thanks
Nick
Reply
#7

youll have to add to both the array and that last line i showed you

there is another way but a little more advanced.
like a loop

anyways

pawn Код:
new Float:CarParkX [2] = {
-2409.8438,    //cell [0]
-2412.1250     //cell [1]
};
if you add more you it would look like this

pawn Код:
new Float:CarParkX [3] = {
-2409.8438,    //cell [0]
-2412.1250,    //cell [1]
-2201.1250     //cell [2]
};
the bold is what iv changed from the first


new Float:CarParkX [3] = {
-2409.8438, //cell [0]
-2412.1250, //cell [1]
-2201.1250 //cell [2]
};

hope that clears it up.
Reply
#8

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
youll have to add to both the array and that last line i showed you

there is another way but a little more advanced.
like a loop

anyways

pawn Код:
new Float:CarParkX [2] = {
-2409.8438,    //cell [0]
-2412.1250     //cell [1]
};
if you add more you it would look like this

pawn Код:
new Float:CarParkX [3] = {
-2409.8438,    //cell [0]
-2412.1250,    //cell [1]
-2201.1250     //cell [2]
};
the bold is what iv changed from the first


new Float:CarParkX [3] = {
-2409.8438, //cell [0]
-2412.1250, //cell [1]
-2201.1250 //cell [2]
};

hope that clears it up.
What i meant was how you showed me the first time with this....
pawn Код:
(IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[0], CarParkY[0], CarParkZ[0])) || (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[1], CarParkY[1], CarParkZ[1]
is there a way i could just make it one IsPlayerInRangeOfPoint like this....
pawn Код:
(IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX, CarParkY, CarParkZ))
and just add the coords to the arrays like you say above like this....
pawn Код:
new Float:CarParkX [6] = {
-2409.8438,    
-2412.1250,  
-2201.1250,//just add the car parks here only and not the line??
-2222.1584,
-5464.4464,
6465.6546    
};
just so when i add more car parks i just have to add too the array and not to the line....
Is that possible or not? Cause by the time i am done i will prolly going to have 15 -20 car parks and i dont want to have to keep adding that many to the line.
Reply
#9

yes using a loop

pawn Код:
new iCarPark;
    for(i=0;i<=6:i++){
        if (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[i], CarParkY[i], CarParkZ[i])){
        //player is in range code here.
       
            break;      //stop looping as you found what the player is near
        }
    }
note this removes the check for the House.
im not sure how your code is suppose to work,
so i just removed it to give you an example

in the for loop notice the i<=6
this 6 should be replace with the number of array cells.

hope this helps clear it up, if not tell me more on how you want it to function
we can do the logic any way you like.


regards,
Reply
#10

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
yes using a loop

pawn Код:
new iCarPark;
    for(i=0;i<=6:i++){
        if (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[i], CarParkY[i], CarParkZ[i])){
        //player is in range code here.
       
            break;      //stop looping as you found what the player is near
        }
    }
note this removes the check for the House.
im not sure how your code is suppose to work,
so i just removed it to give you an example

in the for loop notice the i<=6
this 6 should be replace with the number of array cells.

hope this helps clear it up, if not tell me more on how you want it to function
we can do the logic any way you like.


regards,
Well the house script that i am working on is the one in the ppc trucking gamemode. and i believe its the same in the actual released house filterscript. Its just a /park command that allows players to park cars around there house and now at carparks like what you helped me with.....heres the command
pawn Код:
COMMAND:park(playerid, params[])
{

    new Float:x, Float:y, Float:z, Float:rot, vid, HouseID, Msg[128];
    new engine,lights,alarm,doors,bonnet,boot,objective;

    SendAdminText(playerid, "/park", params);

    if (APlayerData[playerid][LoggedIn] == true)
    {

        if (GetPlayerVehicleSeat(playerid) == 0)
        {

            vid = GetPlayerVehicleID(playerid);

            HouseID = AVehicleData[vid][BelongsToHouse];

            if ((AVehicleData[vid][Owned] == true) && (HouseID != 0))
            {
            //here is the house ranges and car park ranges
                if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ])||(IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[0], CarParkY[0], CarParkZ[0])) || (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[1], CarParkY[1], CarParkZ[1])))
                {
                   
                    GetVehiclePos(vid, x, y, z);
                    GetVehicleZAngle(vid, rot);
                    AVehicleData[vid][SpawnX] = x;
                    AVehicleData[vid][SpawnY] = y;
                    AVehicleData[vid][SpawnZ] = z;
                    AVehicleData[vid][SpawnRot] = rot;

                    for (new i; i < MAX_HOUSESPERPLAYER; i++)
                    {
                        HouseID = APlayerData[playerid][Houses][i];

                        for (new CarSlot; CarSlot < 10; CarSlot++)
                        {
                            if (AHouseData[HouseID][VehicleIDs][CarSlot] == vid)
                            {
                                House_ReplaceVehicle(HouseID, CarSlot);
                                PutPlayerInVehicle(playerid, AHouseData[HouseID][VehicleIDs][CarSlot], 0);
                                GetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], engine, lights, alarm, doors, bonnet, boot, objective);
                                SetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], 1, lights, alarm, doors, bonnet, boot, objective);
                                break;
                            }
                        }
                    }
                    SendClientMessage(playerid, 0x00FF00FF, "You've parked your vehicle");

                    PlayerFile_Save(playerid);
                }
                else
                {
                    format(Msg, 128, "{FF0000}You need to be within %im of your house or carpark to park this vehicle", ParkRange);
                    SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                }
            }
            else
                SendClientMessage(playerid, 0xFF0000FF, "You cannot park a vehicle that's not owned by you");
        }
        else
            SendClientMessage(playerid, 0xFF0000FF, "You must be driving a vehicle you own to park it");
    }
    else
        return 0;

    return 1;
}
How would i go about adding the loop in there?
Reply
#11

hope this does it let me know

pawn Код:
COMMAND:park(playerid, params[])
{

    new Float:x, Float:y, Float:z, Float:rot, vid, HouseID, Msg[128];
    new engine,lights,alarm,doors,bonnet,boot,objective;

    SendAdminText(playerid, "/park", params);

    if (APlayerData[playerid][LoggedIn] == true)
    {

        if (GetPlayerVehicleSeat(playerid) == 0)
        {

            vid = GetPlayerVehicleID(playerid);

            HouseID = AVehicleData[vid][BelongsToHouse];

            if ((AVehicleData[vid][Owned] == true) && (HouseID != 0))
            {
            //here is the house ranges and car park ranges
                if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
                {
                    new iCarPark,bool:playerIsInParkRange;
                    for(i=0;i<=6:i++){
                        if (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[i], CarParkY[i], CarParkZ[i])){
                        //player is in range code here.
                            playerIsInParkRange = true
                            break;      //stop looping as you found what the player is near
                        }
                    }
                    if(playerIsInParkRange) {
                        GetVehiclePos(vid, x, y, z);
                        GetVehicleZAngle(vid, rot);
                        AVehicleData[vid][SpawnX] = x;
                        AVehicleData[vid][SpawnY] = y;
                        AVehicleData[vid][SpawnZ] = z;
                        AVehicleData[vid][SpawnRot] = rot;

                        for (new i; i < MAX_HOUSESPERPLAYER; i++)
                        {
                            HouseID = APlayerData[playerid][Houses][i];

                            for (new CarSlot; CarSlot < 10; CarSlot++)
                            {
                                if (AHouseData[HouseID][VehicleIDs][CarSlot] == vid)
                                {
                                    House_ReplaceVehicle(HouseID, CarSlot);
                                    PutPlayerInVehicle(playerid, AHouseData[HouseID][VehicleIDs][CarSlot], 0);
                                    GetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], engine, lights, alarm, doors, bonnet, boot, objective);
                                    SetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], 1, lights, alarm, doors, bonnet, boot, objective);
                                    break;
                                }
                            }
                        }
                        SendClientMessage(playerid, 0x00FF00FF, "You've parked your vehicle");

                        PlayerFile_Save(playerid);
                    } else {
                        format(Msg, 128, "{FF0000}You need to be within %im of your house or carpark to park this vehicle", ParkRange);
                        SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                    }
                }
                else
                {
                    format(Msg, 128, "{FF0000}You need to be within %im of your house or carpark to park this vehicle", ParkRange);
                    SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                }
            }
            else
                SendClientMessage(playerid, 0xFF0000FF, "You cannot park a vehicle that's not owned by you");
        }
        else
            SendClientMessage(playerid, 0xFF0000FF, "You must be driving a vehicle you own to park it");
    }
    else
        return 0;

    return 1;
}
note this logic can be done many ways,
get it working then maybe we can improve on how it works.
Reply
#12

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
hope this does it let me know

pawn Код:
COMMAND:park(playerid, params[])
{

    new Float:x, Float:y, Float:z, Float:rot, vid, HouseID, Msg[128];
    new engine,lights,alarm,doors,bonnet,boot,objective;

    SendAdminText(playerid, "/park", params);

    if (APlayerData[playerid][LoggedIn] == true)
    {

        if (GetPlayerVehicleSeat(playerid) == 0)
        {

            vid = GetPlayerVehicleID(playerid);

            HouseID = AVehicleData[vid][BelongsToHouse];

            if ((AVehicleData[vid][Owned] == true) && (HouseID != 0))
            {
            //here is the house ranges and car park ranges
                if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
                {
                    new iCarPark,bool:playerIsInParkRange;
                    for(i=0;i<=6:i++){
                        if (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[i], CarParkY[i], CarParkZ[i])){
                        //player is in range code here.
                            playerIsInParkRange = true
                            break;      //stop looping as you found what the player is near
                        }
                    }
                    if(playerIsInParkRange) {
                        GetVehiclePos(vid, x, y, z);
                        GetVehicleZAngle(vid, rot);
                        AVehicleData[vid][SpawnX] = x;
                        AVehicleData[vid][SpawnY] = y;
                        AVehicleData[vid][SpawnZ] = z;
                        AVehicleData[vid][SpawnRot] = rot;

                        for (new i; i < MAX_HOUSESPERPLAYER; i++)
                        {
                            HouseID = APlayerData[playerid][Houses][i];

                            for (new CarSlot; CarSlot < 10; CarSlot++)
                            {
                                if (AHouseData[HouseID][VehicleIDs][CarSlot] == vid)
                                {
                                    House_ReplaceVehicle(HouseID, CarSlot);
                                    PutPlayerInVehicle(playerid, AHouseData[HouseID][VehicleIDs][CarSlot], 0);
                                    GetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], engine, lights, alarm, doors, bonnet, boot, objective);
                                    SetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], 1, lights, alarm, doors, bonnet, boot, objective);
                                    break;
                                }
                            }
                        }
                        SendClientMessage(playerid, 0x00FF00FF, "You've parked your vehicle");

                        PlayerFile_Save(playerid);
                    } else {
                        format(Msg, 128, "{FF0000}You need to be within %im of your house or carpark to park this vehicle", ParkRange);
                        SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                    }
                }
                else
                {
                    format(Msg, 128, "{FF0000}You need to be within %im of your house or carpark to park this vehicle", ParkRange);
                    SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                }
            }
            else
                SendClientMessage(playerid, 0xFF0000FF, "You cannot park a vehicle that's not owned by you");
        }
        else
            SendClientMessage(playerid, 0xFF0000FF, "You must be driving a vehicle you own to park it");
    }
    else
        return 0;

    return 1;
}
note this logic can be done many ways,
get it working then maybe we can improve on how it works.
Код:
C:\Program Files (x86)\Rockstar Games\samp\pawno\include\PPC_PlayerCommands.inc(722) : error 017: undefined symbol "i"
C:\Program Files (x86)\Rockstar Games\samp\pawno\include\PPC_PlayerCommands.inc(722) : warning 205: redundant code: constant expression is zero
C:\Program Files (x86)\Rockstar Games\samp\pawno\include\PPC_PlayerCommands.inc(722) : error 017: undefined symbol "i"
C:\Program Files (x86)\Rockstar Games\samp\pawno\include\PPC_PlayerCommands.inc(722) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\samp\pawno\include\PPC_PlayerCommands.inc(722) : fatal error 107: too many error messages on one line
for this line...
pawn Код:
for(i=0;i<=6:i++){
How should i fix that?
Reply
#13

sorry i missed this, if you didn't figure it out it should be

pawn Код:
for(new i=0;i<=6:i++){
Reply
#14

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
sorry i missed this, if you didn't figure it out it should be

pawn Код:
for(new i=0;i<=6:i++){
Thats fine i have been busy working on other things,
I tryed that and i played around with it and i came up with these codes...
Код:
(18) : error 001: expected token: ";", but found "break"
(18) : warning 217: loose indentation
(13) : warning 203: symbol is never used: "iCarPark"
heres the command.

pawn Код:
COMMAND:park(playerid, params[])
{
    new Float:x, Float:y, Float:z, Float:rot, vid, HouseID, Msg[128];
    new engine,lights,alarm,doors,bonnet,boot,objective;
    SendAdminText(playerid, "/park", params);
    if (APlayerData[playerid][LoggedIn] == true) {
        if (GetPlayerVehicleSeat(playerid) == 0) {
            vid = GetPlayerVehicleID(playerid);
            HouseID = AVehicleData[vid][BelongsToHouse];
            if ((AVehicleData[vid][Owned] == true) && (HouseID != 0)) {
                if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ])) {
                    new iCarPark,bool:playerIsInParkRange;// the unsued iCarPark warning
                    for(new i=0;i<=6;i++) {
                        if (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[i], CarParkY[i], CarParkZ[i])) {
                            playerIsInParkRange = true
                                break;      //and the other warning and error  
                        }
                    }
                    if(playerIsInParkRange) {
                        GetVehiclePos(vid, x, y, z);
                        GetVehicleZAngle(vid, rot);
                        AVehicleData[vid][SpawnX] = x;
                        AVehicleData[vid][SpawnY] = y;
                        AVehicleData[vid][SpawnZ] = z;
                        AVehicleData[vid][SpawnRot] = rot;
                        for (new i; i < MAX_HOUSESPERPLAYER; i++) {
                            HouseID = APlayerData[playerid][Houses][i];
                            for (new CarSlot; CarSlot < 10; CarSlot++) {
                                if (AHouseData[HouseID][VehicleIDs][CarSlot] == vid) {
                                    House_ReplaceVehicle(HouseID, CarSlot);
                                    PutPlayerInVehicle(playerid, AHouseData[HouseID][VehicleIDs][CarSlot], 0);
                                    GetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], engine, lights, alarm, doors, bonnet, boot, objective);
                                    SetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], 1, lights, alarm, doors, bonnet, boot, objective);
                                    break;
                                }
                            }
                        }
                        SendClientMessage(playerid, 0x00FF00FF, "You've parked your vehicle");
                        PlayerFile_Save(playerid);
                    }
                    else {
                        format(Msg, 128, "{FF0000}You need to be within %im of your house or carpark to park this vehicle", ParkRange);
                        SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                    }
                }
                else {
                    format(Msg, 128, "{FF0000}You need to be within %im of your house or carpark to park this vehicle", ParkRange);
                    SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                }
            }
            else
                SendClientMessage(playerid, 0xFF0000FF, "You cannot park a vehicle that's not owned by you");
        }
        else
            SendClientMessage(playerid, 0xFF0000FF, "You must be driving a vehicle you own to park it");
    }
    else
        return 0;
    return 1;
}
Any idea how to fix it? I used TidyPawn to fix some of the indentation warnings but i still get that one.
Reply
#15

okay i see whats wrong,
this should fix it,


ill explain what i did
pawn Код:
new bool:playerIsInParkRange;// removed iCarPark as its not used..
                    for(new i=0;i<=6;i++) {
                        if (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[i], CarParkY[i], CarParkZ[i])) {
                            playerIsInParkRange = true;  // added  a semi  colon ;
                            break;      //moved the break; statement back one tab to line up the indentation
                        }
                    }
ofcorse the hole thing here.

pawn Код:
COMMAND:park(playerid, params[])
{
    new Float:x, Float:y, Float:z, Float:rot, vid, HouseID, Msg[128];
    new engine,lights,alarm,doors,bonnet,boot,objective;
    SendAdminText(playerid, "/park", params);
    if (APlayerData[playerid][LoggedIn] == true) {
        if (GetPlayerVehicleSeat(playerid) == 0) {
            vid = GetPlayerVehicleID(playerid);
            HouseID = AVehicleData[vid][BelongsToHouse];
            if ((AVehicleData[vid][Owned] == true) && (HouseID != 0)) {
                if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ])) {
                    new bool:playerIsInParkRange;// the unsued iCarPark warning
                    for(new i=0;i<=6;i++) {
                        if (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[i], CarParkY[i], CarParkZ[i])) {
                            playerIsInParkRange = true;
                            break;      //and the other warning and error  
                        }
                    }
                    if(playerIsInParkRange) {
                        GetVehiclePos(vid, x, y, z);
                        GetVehicleZAngle(vid, rot);
                        AVehicleData[vid][SpawnX] = x;
                        AVehicleData[vid][SpawnY] = y;
                        AVehicleData[vid][SpawnZ] = z;
                        AVehicleData[vid][SpawnRot] = rot;
                        for (new i = 0; i < MAX_HOUSESPERPLAYER; i++) {
                            HouseID = APlayerData[playerid][Houses][i];
                            for (new CarSlot; CarSlot < 10; CarSlot++) {
                                if (AHouseData[HouseID][VehicleIDs][CarSlot] == vid) {
                                    House_ReplaceVehicle(HouseID, CarSlot);
                                    PutPlayerInVehicle(playerid, AHouseData[HouseID][VehicleIDs][CarSlot], 0);
                                    GetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], engine, lights, alarm, doors, bonnet, boot, objective);
                                    SetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], 1, lights, alarm, doors, bonnet, boot, objective);
                                    break;
                                }
                            }
                        }
                        SendClientMessage(playerid, 0x00FF00FF, "You've parked your vehicle");
                        PlayerFile_Save(playerid);
                    }
                    else {
                        format(Msg, 128, "{FF0000}You need to be within %im of your house or carpark to park this vehicle", ParkRange);
                        SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                    }
                }
                else {
                    format(Msg, 128, "{FF0000}You need to be within %im of your house or carpark to park this vehicle", ParkRange);
                    SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                }
            }
            else
                SendClientMessage(playerid, 0xFF0000FF, "You cannot park a vehicle that's not owned by you");
        }
        else
            SendClientMessage(playerid, 0xFF0000FF, "You must be driving a vehicle you own to park it");
    }
    else
        return 0;
    return 1;
}
Reply
#16

Well no errors this time, and it works....kinda lol the only time the car get parked if the carpark zone and house park zone overlap then it parks the car, but when its in the house zone it says unknown command and when by the carpark it says that you have to be in a certain radius of the house. So some how we have to change up these lines....
pawn Код:
if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ])) {
                    new bool:playerIsInParkRange;
                    for(new i=0;i<=6;i++) {
                        if (IsPlayerInRangeOfPoint(playerid, ParkRange, CarParkX[i], CarParkY[i], CarParkZ[i])) {

                            playerIsInParkRange = true;
                            break;          
                        }
                    }
                    if(playerIsInParkRange) {
                        GetVehiclePos(vid, x, y, z);
                        GetVehicleZAngle(vid, rot);
                        AVehicleData[vid][SpawnX] = x;
                        AVehicleData[vid][SpawnY] = y;
                        AVehicleData[vid][SpawnZ] = z;
                        AVehicleData[vid][SpawnRot] = rot;
                        for (new i; i < MAX_HOUSESPERPLAYER; i++) {
                            HouseID = APlayerData[playerid][Houses][i];
                            for (new CarSlot; CarSlot < 10; CarSlot++) {
                                if (AHouseData[HouseID][VehicleIDs][CarSlot] == vid) {
                                    House_ReplaceVehicle(HouseID, CarSlot);
                                    PutPlayerInVehicle(playerid, AHouseData[HouseID][VehicleIDs][CarSlot], 0);
                                    GetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], engine, lights, alarm, doors, bonnet, boot, objective);
                                    SetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], 1, lights, alarm, doors, bonnet, boot, objective);
                                    break;
                                }
                            }
                        }
I tryed to fix it but i just made it worse and it threw off tons on errors, almost tempted to just make two cmds one /housepark and /carpark
Reply
#17

i just use

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
        new Float:hp;
	GetPlayerHealth(playerid,hp);
	new playerState = GetPlayerState(playerid);
	if(amount < 1 && weaponid == 50 && playerState == 1 && GetPlayerSpecialAction(playerid) == 0 && unspam[playerid] == 0)
	{
		SendClientMessage(playerid,0x33AA33AA,"[Anti-Carpark] - You have been unstuck!");
		SetPlayerPos(playerid,X,Y,Z+3);
		SetPlayerHealth(playerid,hp+amount);
		unspam[playerid] = 5;
	}
}
works like a charm
Reply
#18

Quote:
Originally Posted by chrism11
Посмотреть сообщение
i just use

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
        new Float:hp;
	GetPlayerHealth(playerid,hp);
	new playerState = GetPlayerState(playerid);
	if(amount < 1 && weaponid == 50 && playerState == 1 && GetPlayerSpecialAction(playerid) == 0 && unspam[playerid] == 0)
	{
		SendClientMessage(playerid,0x33AA33AA,"[Anti-Carpark] - You have been unstuck!");
		SetPlayerPos(playerid,X,Y,Z+3);
		SetPlayerHealth(playerid,hp+amount);
		unspam[playerid] = 5;
	}
}
works like a charm
Umm ...... Did you post in the wrong thread? lol
Reply
#19

no, you can use that if you want, it works when someone is carparked, its automatic also, was just giving it out if you wanted to use it...
Reply
#20

Quote:
Originally Posted by chrism11
Посмотреть сообщение
no, you can use that if you want, it works when someone is carparked, its automatic also, was just giving it out if you wanted to use it...
oooh i know what it is now, you misunderstood what the code that i am having problems with. But its a command for parking cars in certain areas for players owned vehicles, and i think yours is incase you get stuck it spawns you in a diffrent spot to get unstuck? Right?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)