[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
#2

Haha, awesome!
Reply
#3

original idea.
Reply
#4

Correct me if I'm wrong, but that looks like a cow.
Reply
#5

Quote:
Originally Posted by MP2
Посмотреть сообщение
Correct me if I'm wrong, but that looks like a cow.
Like I said:
Quote:
Originally Posted by Correlli
Посмотреть сообщение
Unfortunately, there is no horse-object in SA:MP as far as I know, so I was forced to use cow-object.
But if you're referring to the "dog cart", then I guess I can't really help you here:
http://en.wikipedia.org/wiki/Dogcart
Reply
#6

Random and original as fuck
Reply
#7

EDIT: Good work mate.

BUGS:
1.When ever im riding the cart using /cart and im over 9.0 speed. I release Up and Press Down then the cart is respawned and it says you have disabled the cart.

Tapping the down button While Riding the cart over 9.0 or sometimes less makes it Destroy The Cart also.
it is happening because of dc_timer i think.

2. The Cart can go through any object [i.e. anything and goes everywhere].

3. Try riding the cart up to a hill or inclined road , It doesnt set the angle according to the road's angle so that it can go up as a result it fails to take the player up the road/hill and goes through the object and player remains at the road.

Is that all can be fixed via MapAndreas Plugin? Is it possible to detect rotation according to objects and when Object touches an existing object.


Please fix it dude. Love the include awesome work.

Quote:
Originally Posted by Correlli
Посмотреть сообщение
But if you're referring to the "dog cart", then I guess I can't really help you here:
http://en.wikipedia.org/wiki/Dogcart
Yeah true that.
Reply
#8

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
1.When ever im riding the cart using /cart and im over 9.0 speed. I release Up and Press Down then the cart is respawned and it says you have disabled the cart.

Tapping the down button While Riding the cart over 9.0 or sometimes less makes it Destroy The Cart also.
it is happening because of dc_timer i think.
Quote:
Originally Posted by Correlli
Посмотреть сообщение
MAX_DOG_CART_SPEED - The maximum speed of the cart. It shouldn't be too big.
- The maximum "reached speed" shouldn't be too big, even speed of 10.0 is too big for some people. I hope the object synchronisation will get better in the next version of SA:MP. However, you can increase the interval of the "dc_Timer" timer.



Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
2. The Cart can go through any object [i.e. anything and goes everywhere].

3. Try riding the cart up to a hill or inclined road , It doesnt set the angle according to the road's angle so that it can go up as a result it fails to take the player up the road/hill and goes through the object and player remains at the road.
Quote:
Originally Posted by Correlli
Посмотреть сообщение
It will also automatically re-spawn if you drive into the object (example - mountain).

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Is that all can be fixed via MapAndreas Plugin? Is it possible to detect rotation according to objects and when Object touches an existing object.
Quote:
Originally Posted by Correlli
Посмотреть сообщение
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.
- Using such plugin/include in "OnPlayerUpdate" callback isn't a good idea (Dog-cart include is working with OnPlayerUpdate callback).
Reply
#9

Quote:
Originally Posted by Correlli
Посмотреть сообщение
- The maximum "reached speed" shouldn't be too big, even speed of 10.0 is too big for some people. I hope the object synchronisation will get better in the next version of SA:MP. However, you can increase the interval of the "dc_Timer" timer.
I have the default speed which is 10.0 , All though i've fixed that problem of automatic respawn in my version of this include.

Quote:
Originally Posted by Correlli
Посмотреть сообщение
- Using such plugin/include in "OnPlayerUpdate" callback isn't a good idea (Dog-cart include is working with OnPlayerUpdate callback).
Why not? So what do you say , Is there anything which can be done? What about Mauzen's version of MapAndreas? It uses less RAM in comparison to the previous version.
Reply
#10

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Why not? So what do you say , Is there anything which can be done? What about Mauzen's version of MapAndreas? It uses less RAM in comparison to the previous version.
You can change code so it will work without OnPlayerUpdate, because this callback gets called a lot and that's why I don't see using the MapAndreas plugin/include inside this callback as a good idea.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)