/park command
#1

Hey!

Okey, I've tried to think of how to make this work.

But I got this Vehicle System that saves players vehicles into 1 .ini file like this:
Код:
 
{Daniel_Lan:FC-126643:581:0:0:61.145141:1189.521240:18.826271:260.695800}
{Daniel_Lan:FC-135699:541:79:79:-302.306884:1745.964477:42.414600:91.546401}
{Sam_Jukonen:FC-571386:461:3:3:-301.295410:1779.988891:42.414600:89.990196}
{Sam_Jukonen:FC-658415:509:3:3:-301.295410:1779.988891:42.414600:89.990196}
If you are interested it saves like this:

pawn Код:
// [Stuff that gets all the variables etc, and at end this:]
new File:carfile = fopen(CARMOD_FILE_LOC, io_append);
if(carfile)
{
    // {owner:plate:model:col:col2:x:y:z:ang} (Just to explain what is what)
    new cmd2[1024];
    format(cmd2, sizeof(cmd2), "{%s:%s:%i:%i:%i:%f:%f:%f:%f}\r\n", vehOwner, vehPlate, vehModel, vehCol1, vehCol2, vehX, vehY, vehZ, vehAng);
    fwrite(carfile, cmd2);
    fclose(carfile);
}
But what I want is a /park command. That gets the player in vehicle, matches it to the vehicles license plate.

Just to proof the current person inside the car running /park command is the owner of vehicle.
And if the person has more then 1 vehicle, I used plate numbers to identify the correct vehicle.

So how far I think I managed to fix, but the problem comes to open the file, find the license number to get the correct line I want to edit. And then overwrite old X, Y, Z and Angle to the current one.
So the vehicle from then on would spawn there.

pawn Код:
if(!strcmp("/park", cmdtext, true))
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new tmpcar = GetPlayerVehicleID(playerid);
                if(IsVehicleOwned[tmpcar])
                {
                    if(strcmp(vehOwnerName[tmpcar], plyName, true) == 0)
                    {

                        //LicensePlate[tmpcar] <<-- This gets the current vehicles license plate
                       
                        // What to do now?
                       
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_CMD, "     - You don't own this Vehicle !");
                        return 1;
                    }
                   
                }
                else
                {
                    SendClientMessage(playerid, COLOR_CMD, "     - You're not inside a owned Vehicle !");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_CMD, "     - You must be in a vehicle to park one !");
                return 1;
            }
        }
        return 1;
    }
Please make the rest there, I don't know how to make it. And it gives me a head cache lol, I can't think of how
If you need some other parts of code to make this, let me know !

My problem is to find the correct line and replace it correctly. Thank you very much if you could help!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)