[Tutorial] How to create your own vehicle system
#21

Oops, I totally forgot about this tutorial, just got reminded by someone who PMed me about it

@Dirkon: The error is caused by a stupid mistake i made.
stock CreateVehicleEx(modelid, Float: x, Float:y, Float:z, Float:angle, color1, color2, respawntime, ownername[20])
has to be
stock CreateVehicleEx(modelid, Float: x, Float:y, Float:z, Float:angle, color1, color2, respawntime, ownername[MAX_PLAYER_NAME])
of course, and the array size of owner in carDataEnum has to be MAX_PLAYER_NAME too. (I also updated the first post now)

@bijoyekuza: The owner is what you set in CreateVehicleEx, and you can simply get it with carData[vehicleid][owner]. The code you made should do it.
For a /park command just change the x/y/zspawn coordinates for carData[vehicleid], as well as the rotation of it (anglespawn) and add this to the top of your OnVehicleSpawn callback:
pawn Code:
SetVehiclePos(vehicleid, carData[vehicleid][xspawn], carData[vehicleid][yspawn], carData[vehicleid][zspawn]);
// This will teleport the vehicle to its updated spawn position on spawn
SetVehicleZAngle(vehicleid, carData[vehicleid][anglespawn]);
// and sets it rotation to the stored spawn angle.
Reply
#22

Could you make car respawning cmd example?
Reply
#23

Quote:
Originally Posted by Dirkon
View Post
Could you make car respawning cmd example?
Respawning the car itself isnt hard. It is just
SetVehicleToRespawn(vehicleid);

But in order to make it fully compatible with this system you have to add the lines I posted before in your OnVehicleRespawn, so it spawns at the right coordinates, if you change them in the script.
Reply
#24

SetVehicleToRespawn(vehicleid); Just Respawns vehicle where it was when I started the server. What I want to do is lets say /parkvehicle (already done this) and the when I type /respawnvehicles vehicles would respawn at the parked places. I tried to make /respawn like this:
pawn Code:
if (strcmp("/respawn", cmdtext, true, 10) == 0)
    {
        SaveAllVehicles();
        DestroyAllVehicles();
        LoadAllVehicles();
        return 1;
    }
But it doesn't really work. When I respawn vehicles for a first time everything seems to be fine, but when I try to respawn them for the second time all cars gets doubled.

P.S. sorry for possible grammar mistakes.
Reply
#25

pawn Code:
C:\Users\Atar\Desktop\car.pwn(178) : error 017: undefined symbol "ini_CreateIniFile"
C:\Users\Atar\Desktop\car.pwn(179) : error 017: undefined symbol "ini_SetInt"
C:\Users\Atar\Desktop\car.pwn(180) : error 017: undefined symbol "ini_SetFloat"
C:\Users\Atar\Desktop\car.pwn(182) : error 017: undefined symbol "ini_CloseIni"
C:\Users\Atar\Desktop\car.pwn(178) : warning 204: symbol is assigned a value that is never used: "iniid"
C:\Users\Atar\Desktop\car.pwn(201) : warning 217: loose indentation
C:\Users\Atar\Desktop\car.pwn(201) : error 029: invalid expression, assumed zero
C:\Users\Atar\Desktop\car.pwn(201) : error 017: undefined symbol "LoadVehicle"
C:\Users\Atar\Desktop\car.pwn(201) : warning 215: expression has no effect
C:\Users\Atar\Desktop\car.pwn(201) : error 001: expected token: ";", but found "]"
C:\Users\Atar\Desktop\car.pwn(201) : fatal error 107: too many error messages on one line
Reply
#26

Is useful for the newbie good job !
Reply
#27

Yeah this Car System Is useless.. No Replies... heh
Reply
#28

Nice job.
Reply
#29

Bringing this back to the top.
There seems to be a bug in the GetFreeVehicleSlot, when I create a user's vehicle, I get put in an other car at LSPD :O
Reply
#30

This is not work for me either. The stocks don't work for 100% and in this is not a tutorial, because it does not learn you how to make it work.
Reply
#31

Quote:
Originally Posted by [PC]henkie[NL]
View Post
This is not work for me either. The stocks don't work for 100% and in this is not a tutorial, because it does not learn you how to make it work.
My Point Exactly.....
Reply
#32

Bumping answers

Quote:
Originally Posted by [PC]henkie[NL]
View Post
This is not work for me either. The stocks don't work for 100% and in this is not a tutorial, because it does not learn you how to make it work.
Then explain what the problem is with them. As I said at the very beginning this was a topic answer, and not a planned tutorial, so it is written for the guy who asked for it, and might not be perfect understandable for everyone.
So it depends on feedback and problem reports if I can update it.

Also the vehicleid of created vehicles isnt stored in this tutorial, and this is a quite big disadvantage for most uses: The "carid" used in these stocks is NOT the vehicleid used in samp.
Reply
#33

Really good.
Reply
#34

Scripting a new vehicle is not hard ( you can in a fact put one object and some handling, colliders and thats it ) but I love how this topic is more then that. ( Yes I made a ,,cowcar,, witch was not bad in one way, but in another way, all players that loved farming hated how much it's handling is retarded (copied the one from Tractor). I mean I didn't want to place Infernus handling. It would be weird. A cow faster then a car :P
Anyways, this is a really solid 10/10. I don't know how much it took you for the other stuff but it's genius. I would never think to make it more then just object with handling. Great work! +REP
Reply
#35

No errors but car doesnt appear on server , where I put , when I compiled no errors , I made exactly like you ! Help ? +rep
Reply
#36

Veery veery nice, good job dude!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)