SA-MP Forums Archive
/veh park command, not working... - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /veh park command, not working... (/showthread.php?tid=193062)



/veh park command, not working... - Ash. - 24.11.2010

I have the following script to save the x, y, and z co-ordinates of a vehicle that is owned by a player on my server.
Each player has 5 vehicle slots. Stored in files using dini (and dubd for encryption purposes)

Here is the code:
pawn Код:
if(IsPlayerInAnyVehicle(playerid) == 1)
        {
            new file[64], pName[MAX_PLAYER_NAME], vfile[64];
            GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
            format(file, sizeof(file), "vehicle/accounts/%s.veh", pName);
            for(new i; i < 1000; i++)
            {
                if(IsPlayerInVehicle(playerid, PlayerVData[i]) == 1)
                {
                    new Float:vx, Float:vy, Float:vz;
                    GetVehiclePos(GetPlayerVehicleID(playerid), vx, vy, vz);
                    if(dini_Int(file, "1") == PlayerVData[i])
                    {
                        format(vfile, sizeof(vfile), "vehicle/%i", dini_Int(file, "1"));
                        dini_FloatSet(vfile, "x", vx);
                        dini_FloatSet(vfile, "y", vy);
                        dini_FloatSet(vfile, "z", vz);
                        new string[64];
                        format(string, sizeof(string), "Your vehicle (%s) has been parked here!", dini_Get(vfile, "VName"));
                        SendClientMessage(playerid, VEHICLE_COLOUR, string);
                    }
                    else if(dini_Int(file, "2") == PlayerVData[i])
                    {
                        format(vfile, sizeof(vfile), "vehicle/%i", dini_Int(file, "2"));
                        dini_FloatSet(vfile, "x", vx);
                        dini_FloatSet(vfile, "y", vy);
                        dini_FloatSet(vfile, "z", vz);
                        new string[64];
                        format(string, sizeof(string), "Your vehicle (%s) has been parked here!", dini_Get(vfile, "VName"));
                        SendClientMessage(playerid, VEHICLE_COLOUR, string);
                    }
                    else if(dini_Int(file, "3") == PlayerVData[i])
                    {
                        format(vfile, sizeof(vfile), "vehicle/%i", dini_Int(file, "3"));
                        dini_FloatSet(vfile, "x", vx);
                        dini_FloatSet(vfile, "y", vy);
                        dini_FloatSet(vfile, "z", vz);
                        new string[64];
                        format(string, sizeof(string), "Your vehicle (%s) has been parked here!", dini_Get(vfile, "VName"));
                        SendClientMessage(playerid, VEHICLE_COLOUR, string);
                    }
                    else if(dini_Int(file, "4") == PlayerVData[i])
                    {
                        format(vfile, sizeof(vfile), "vehicle/%i", dini_Int(file, "4"));
                        dini_FloatSet(vfile, "x", vx);
                        dini_FloatSet(vfile, "y", vy);
                        dini_FloatSet(vfile, "z", vz);
                        new string[64];
                        format(string, sizeof(string), "Your vehicle (%s) has been parked here!", dini_Get(vfile, "VName"));
                        SendClientMessage(playerid, VEHICLE_COLOUR, string);
                    }
                    else if(dini_Int(file, "5") == PlayerVData[i])
                    {
                        format(vfile, sizeof(vfile), "vehicle/%i", dini_Int(file, "5"));
                        dini_FloatSet(vfile, "x", vx);
                        dini_FloatSet(vfile, "y", vy);
                        dini_FloatSet(vfile, "z", vz);
                        new string[64];
                        format(string, sizeof(string), "Your vehicle (%s) has been parked here!", dini_Get(vfile, "VName"));
                        SendClientMessage(playerid, VEHICLE_COLOUR, string);
                    }
                }
            }
        }
Let me explain a few things...
pawn Код:
PlayerVData
is defined earlier in the script - it has 1000 slots because (if my calculations are correct) the maximum number of purchased vehicles will be 1000.

vfile, is the vehicle file (vehicle/vehicleid.veh) and file is the players file (vehicle/accounts/playername.veh)
vfile holds the vehicle information, and file holds the 5 vehicle id's for that player.

(im using dcmd, so i can have one main command (/veh) and then 'params' is the sub command - in this case 'park')

Scenario
I have the vehicle where i want it - i type /veh park, and if it parked succesfully, it should say
"Your vehicle (Vehicle Name) has been parked here!"
however it doesnt. It doesnt say anything.

It should check GetPlayerVehicleID(playerid) against PlayerVData[i] (looped = i = 0 < 1000) - if it matches it runs another if. If the PlayerVData[i] matches an ID in the players account file, it knows that that specific player owns that vehicle. Then it will right the 'x', 'y' and 'z' co-ordinates to the {vehicleid}.veh file.

Can anyone see a problem / does anyone know a solution?

Thanks
Ash


Re: /veh park command, not working... - Ash. - 25.11.2010

-Bump-

This message is too short


Re: /veh park command, not working... - rbN. - 25.11.2010

None of your dini_ints are equal to that PlayerVData's.


Re: /veh park command, not working... - Ash. - 25.11.2010

Quote:
Originally Posted by RobinOwnz
Посмотреть сообщение
None of your dini_ints are equal to that PlayerVData's.
They are, because if i print the PlayerVData and the dini_Int information, it matches.