[Include] [INC] Dog cart (driving system)
#1

What is this?
This is a script which allows you to drive on the "dog cart" objects. It can be useful if you want to have some fun. Unfortunately, there is no horse-object in SA:MP as far as I know, so I was forced to use cow-object.


Pictures:
/imageshack/img411/1172/13346910.png
/imageshack/img560/862/25598101.png
/imageshack/img685/4417/79315373.png
/imageshack/img28/5204/86170747.png
/imageshack/img341/2150/11596993.png
/imageshack/img690/6373/82492909.png


Credits:
- ****** for foreach & GetXYInFrontOfPlayer functions,
- ZeeX for zcmd command processor.


How to install?
It's easy and simple - download and put the dc.inc into the \pawno\include\ folder and do the same thing with the foreach.inc and zcmd.inc file.
Open your script and put this:
pawn Код:
#include <foreach>
#include <zcmd>
#include <dc>
right after the
pawn Код:
#include <a_samp>
Put the carts in the OnGameModeInit callback.
Example:
pawn Код:
/*
CreateDogCart(Float:x, Float:y, Float:z, Float:rz = 0.0);
*/

CreateDogCart(1777.5, -1930.4, 13.975, 270.0);
CreateDogCart(1782.5, -1930.4, 13.975, 270.0);
CreateDogCart(1787.5, -1930.4, 13.975, 270.0);
These 3 carts are located at the Los Santos Unity train station. Here are the spawn coordinates:
pawn Код:
1772.5, -1916.4, 13.5527

Functions:
CreateDogCart
Adds the dog cart to the server.
@Float: x = Cart spawn X position.
@Float: y = Cart spawn Y position.
@Float: z = Cart spawn Z position.
@Float: rz = Cart spawn Z rotation.
returns the cart ID which starts with 0. If you exceed the MAX_DOG_CARTS define then it will return the invalid ID which is -1.
Example:
pawn Код:
new
        gCart = -1;

public OnGameModeInit()
{
    gCart = CreateDogCart(1777.5, -1930.4, 13.975, 270.0);
    return true;
}
DestroyDogCart
Deletes the dog cart from the server.
@dcid = The cart ID.
returns true if the cart is valid and false if it's not.
Example:
pawn Код:
DestroyDogCart(gCart);
IsDogCartCreated
Checks if dog cart is created.
@dcid = The cart ID.
returns true if the cart is valid and false if it's not.
Example:
pawn Код:
if(IsDogCartCreated(gCart)) printf("Cart is created.");
else printf("Cart is NOT created.");
StopDogCart
Stops the dog cart.
@dcid = The cart ID.
returns true if the cart is valid and false if it's not.
Example:
pawn Код:
StopDogCart(gCart);
RespawnDogCart
Re-spawns the dog cart.
@dcid = The cart ID.
returns true if the cart is valid and false if it's not.
Example:
pawn Код:
RespawnDogCart(gCart);
SetDogCartSpeed
Sets the speed of the dog cart.
@dcid = The cart ID.
@cartspeed = The speed to set for the cart.
returns true if the cart is valid and false if it's not.
If the you set the speed which is higher than MAX_DOG_CART_SPEED, then the function will automatically set it to the MAX_DOG_CART_SPEED.
Example:
This will set the speed of the cart to 3.5:
pawn Код:
SetDogCartSpeed(gCart, 3.5);
This will set the speed of the cart to the maximum (which is defined with MAX_DOG_CART_SPEED):
pawn Код:
SetDogCartSpeed(gCart);
IsPlayerAtDogCart
Checks if player is near the dog cart.
@playerid = The ID of the player.
@dcid = The cart ID.
returns true if the player is near the cart and false if he isn't.
Example:
pawn Код:
if(IsPlayerAtDogCart(playerid, gCart)) printf("Player is near the cart with ID %i.", gCart);
else printf("Player is NOT near the cart with ID %i.", gCart);
IsPlayerAtAnyDogCart
Checks if player is near any dog cart.
@playerid = The ID of the player.
returns ID of the cart which stars with 0 if player is near any cart and -1 is he's not.
Example:
pawn Код:
new
        gCart = IsPlayerAtAnyDogCart(playerid);

if(gCart != -1) printf("Player is near the cart with ID %i.", gCart);
else printf("Player is NOT near any cart.");

Defines:
pawn Код:
#define MAX_DOG_CARTS (5)
#define MAX_DOG_CART_SPEED (10.0)
MAX_DOG_CARTS - The maximum amount of carts allowed for script to load on the server.
MAX_DOG_CART_SPEED - The maximum speed of the cart. It shouldn't be too big.


How to get coordinates for carts?
I myself am using JernejL's REAL Map Editor, in which I place the dog cart objects (ID 3585 for "cart") where I want to have them. This Map Editor is not for people with weak computers, so if you have a weak computer, you can use any other Map Editor. The z rotation is the rotation of the cart.


Download:
http://www.solidfiles.com/d/d18f52287c


Other:
If you want to start with the driving, then get near the cart (jump inside of it or on it) and use the "/cart" command. If you want to stop with the driving, then use the "/cart" command once again.

Use arrow keys (UP, DOWN, LEFT and RIGHT) to control the cart's movement:
arrow UP = forward
arrow DOWN = stopping
arrow LEFT = turn left
arrow RIGHT = turn right

When you delete the last cart then the timer will stop so you don't have to do anything, and when you add the first cart then it will start again.

If you fall of from the cart, then the cart will automatically re-spawn. It will also automatically re-spawn if you drive into the object (example - mountain).

I didn't use MapAndreas (plugin / include) or anything similar, you can't control the cart's height, so there is a "bug" where you can drive / fly over parts (objects) on map which have the lower height than cart.
Reply


Messages In This Thread
[INC] Dog cart (driving system) - by Correlli - 08.08.2012, 21:25
Re: [INC] Dog cart (driving system) - by Fj0rtizFredde - 08.08.2012, 21:28
Re: [INC] Dog cart (driving system) - by noobre - 08.08.2012, 21:48
Re: [INC] Dog cart (driving system) - by MP2 - 08.08.2012, 22:19
Re: [INC] Dog cart (driving system) - by Correlli - 08.08.2012, 22:28
Re: [INC] Dog cart (driving system) - by rbN. - 09.08.2012, 06:20
Re: [INC] Dog cart (driving system) - by Ballu Miaa - 24.08.2012, 04:59
Re: [INC] Dog cart (driving system) - by Correlli - 24.08.2012, 12:35
Re: [INC] Dog cart (driving system) - by Ballu Miaa - 24.08.2012, 13:59
Re: [INC] Dog cart (driving system) - by Correlli - 24.08.2012, 15:33

Forum Jump:


Users browsing this thread: 1 Guest(s)