[Help] Car Ownership System (need just to fix some parts of the code)
#1

Hello, i have some big problems on a FS about the car ownership system.
Credits to: Xalphox (i really like this system as a start because is very RP and i'm editing it for make it suitable for the server i'm going to make)

The script works good but it don't have the commands /buycar, /park, /sellcar so i was trying to make them and well is really hard for me cause i have problem on use the SaveToFile/ReadFromFile functions and i have try to learn but my head it's like to explode XD really cant understand how to fix some things...so let's try to write the problem on forum and HOPE that some one will reply to my.

Name of the file
carmod.ini
What the file contain:
vehOwner = Who own the vehicle
vehPlate = Don't know what is exatcly...
vehModel = Model of the vehicle
vehCol1 = First Color
vehCol2 = Second Color
vehX = X Position
vehY = Y Position
vehZ = Z Position
vehAng = Where the vehicle is pointing


------------------------------------------------------------------------------------------
HERE ARE THE START OF THE COMMANDS I HAVE MADE, I NEED HELP ABOUT COMPLETE THEM
------------------------------------------------------------------------------------------

/buycar
pawn Код:
if(!strcmp("/buycar", cmdtext, true))
    {
        new State;
        State=GetPlayerState(playerid);
        if(State==PLAYER_STATE_DRIVER)
        {
      new vehicleid = GetPlayerVehicleID(playerid);
          if(IsVehicleOwned[vehicleid])
            {
            if(IsVehicleOwned[vehicleid])
                {
                    if(!strcmp(vehOwnerName[vehicleid],("Concessionario")))
                    {
            SendClientMessage(playerid, COLOR_GREEN, "Hai appena acquistato un veicolo!");
            SendClientMessage(playerid, COLOR_GREY, "Aiuto: Il veicolo ti appartiene legalmente, rimarrа per sempre tuo tranne se esplode, perchи sarа distrutto in modo permanente");
//-------------CODE TO INSERT FOR SAVE THE CAR BUYED IN A FILE----------------//
                        // HERE...
//----------------------------------------------------------------------------//
                    }
                    else
                    {
                      SendClientMessage(playerid, COLOR_GREY, "Aiuto: Non puoi acquistare veicoli che sono appartenenti ad altri giocatori!");
                    }
                }
            }
        }
        else
        {
          SendClientMessage(playerid, COLOR_GREY, "Aiuto: Devi stare al posto di guida per comprare un veicolo");
            return 1;
        }
    }
/park
pawn Код:
if(!strcmp("/park", cmdtext, true))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new State;
            State=GetPlayerState(playerid);
            if(State==PLAYER_STATE_DRIVER)
            {
                new vehicleid = GetPlayerVehicleID(playerid);
        new name[200];
                if(IsVehicleOwned[vehicleid])
                {
                    GetPlayerName(playerid, name, sizeof(name));
                    if(!strcmp(vehOwnerName[vehicleid],name))
                    {
                        SendClientMessage(playerid, COLOR_GREY, "Aiuto: Hai parcheggiato un tuo veicolo");
//---------CODE TO INSERT FOR SAVE THE "PARK" POSITION IN A FILE----------//
                        // HERE...
//----------------------------------------------------------------------------//
                    }
                    else
                    {
                      SendClientMessage(playerid, COLOR_GREY, "Aiuto: Non puoi parcheggiare un veicolo che non ti appartiene!");
                    }
                }
            }
            else
            {
              SendClientMessage(playerid, COLOR_GREY, "Aiuto: Non sei al posto di guida!");
            }
        }
        else
        {
          SendClientMessage(playerid, COLOR_GREY, "Aiuto: Per parcheggiare un veicolo devi essere nel suo interno e al posto di guida!");
        }
        return 1;
    }
/sellcar
pawn Код:
if(!strcmp("/sellcar", cmdtext, true))
    {
    new vehicleid = GetPlayerVehicleID(playerid);
        if(IsPlayerInAnyVehicle(playerid))
        {
      new State;
            State=GetPlayerState(playerid);
            if(State==PLAYER_STATE_DRIVER)
            {
            if(IsVehicleOwned[vehicleid])
                {
          new name[200];
          GetPlayerName(playerid, name, sizeof(name));
                    if(!strcmp(vehOwnerName[vehicleid], name))
                    {
            SendClientMessage(playerid, COLOR_GREEN, "Hai appena venduto un veicolo di tua proprietа!");
//-------------CODE TO INSERT FOR SAVE THE CAR SOLD IN A FILE-----------------//
                        // HERE... vehOwnerName MUST CHANGE IN "CONCESSIONARIO"
//----------------------------------------------------------------------------//
                    }
                    else
                    {
                      SendClientMessage(playerid, COLOR_GREY, "Aiuto: Non puoi vendere veicoli che non ti appartengono!");
                    }
                }
            }
            else
            {
              SendClientMessage(playerid, COLOR_GREY, "Aiuto: Non puoi vendere il veicolo se non sei nel suo interno al posto di guida!");
            }
        }
        else
        {
          SendClientMessage(playerid, COLOR_GREY, "Aiuto: Devi stare al posto di guida per vendere un veicolo");
            return 1;
        }
    }
Reply
#2

Where you got problems? Only at /park?
Reply
#3

nope i got problems at edit the file "carmod.ini" with /park , /buycar . /sellcar and the destruction of a vehicle

the file is only one, 1line = 1vehicle, IT'NOT 1file for 1vehicle

/park = set the new position for vheicle respawn, as you can see in the code only the Owner of the vehicle can do park, a "thief" can't park the vehicle of someone other.

/buycar = is simple just change the VehOwnerName of the vehicle saved that have as default "Concessionario" as Owner of the vehicle, if the Owner is for example "Jhon_Smith" then /buycar don't work

/sellcarcon - sell the vehicle to "Concessionario" (it's the place where buy cars don't know how in enlish it's called ^^) = just change the Owner of the vehicle in "Concessionario" if the Owner is different from "Concessionario"... for example it was buyed by someone (Jhon_Smith ) so the Owner of the vehicle is Jhon_Smith, then he do /sellcar and the Owner of the vehicle change in "Concessionario" (then he got X money but i think i can make it, of course any different car have different prices)

-{I would like also to make /sellcarpl <id/nameplayer > <price$>, but i don't know how to make the thing like /accept or /deny, and if the guy who recived the invite do /accept he have money set as his TotalMoney - price$ (while the Seller have TotalMoney + price$) and then the car change the Owner by the guywhosell to theguywhobuy}

●Last thing i need is a function that i can still make at 50%, this function delete, if the car got the owner different from "Concessionario", the vehicle from the list in carmod.ini, this mean a permanent destruction of the vehicle (destroyed = deleted).

i just can't Fullymake these commands cause i have problems in WriteFile/ReadFile (infact i'm not requesting all the code , but i know is a heavy and the most important part of it so..PLEASE support )

Ps: If need the full code i can post it, of course giving the credits to the proper maker, and giving info about what i have edit
Reply
#4

*bump*
Possible over 30 views and just 1 reply?...
i need support for the OpenFile/WriteFile thing...i'm not requesting the full codes just the part of read file and write file/edit file with new values, i have give the info about the file with the variables that it uses someone good at this point would please help me? i can't continue in script if i don't solve this damned problem
__________________
Here is an example of the file


/park = i have make: find if the car have an owner if so then compare the owner name of the car with the player name if them are same then ....
what i need...the code for edit the position X,Y,Z in the file only for that car (ID searched first by name then by model [so the player can have more vehicles, for example search in the file Jhon_Smith then if he is in model 550 search for that model (so need to GetVehicleModel(playerid)) and then edit the X,Y,Z ONLY OF THAT CAR (not all the car owned by Jhon_smith or all car in the file)
----
/buycar = what i have done find if the OwnerName is "Concessionario" if so then....
what i need...the code for edit the OwnerNamer and change it to PlayerName
----
/Sellcarcon= what i have done find if the OwnerName is different from "Concessionario" if so then...
what i need....change the OwnerName in "Concessionario"
----
/Sellcarpl <id/name> <price$>= what i have done if a player is Car Dealer(as job) and is near to another player then...
what i need..the guy recive the deal of the CarDealer with a mex (price of the car) make the thing /accept /deline so if the Guy accept the price of Dealer's car the OwnerName of that car change in Guy PlayerName (if /decline nothing happens just send a message to both the player that says: Transaction Declined or something like that)
----
so last thing is the deletion of the vehicle
what i need if player (ex Jhon_Smith) enter in one of his cars then destroy it, after he destroy the car find in the file all vehicles owned by Jhon_Smith then find the last vehicle [GetVehicleModel(playerid)] and then delete the string (model, owner, col1,col2, x,y,z,angle) so the vehicle will not respawn....this is fully destruction of vehicle i need to do it

of course i will find a way for not let a player have 2 vehicles same model

I need to finish this please some one i need support
Reply
#5

*another bump...*
i just see too many views but no answers might some one please just tell me examples of doing the part of codes (the commands+last thing) for example what callbacks i have to use ecc...?

____________
Edit: Solved can close, thanks anyway
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)