Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- •••• • • •••• ••••• ••••• •• •• ••••• •••••
- • • • • • • • • • • • • •
- •••• • • •••• • ••• • • • • ••••• •
- • • • • • • • • • •
- •••• • •••• • ••••• • • ••••• •••••
- * S32_Rent - Create rent vehicles with just one line!
- * Copyright(c)System32
- * This file is provided as is (no warranties)
- * Functions: 13
- * Credits:
- * System32 - Almost everything!
- * Y_Less - y_hooks, y_timers & foreach!
- * That is basically it, have fun with this include and easy scripting!
- */
- #include <a_samp>
- #include <YSI\y_timers>
- #include <YSI\y_hooks>
- #include <foreach>
- #define MAX_RENT_VEHICLES 100
- new Iterator: RentVehicles<MAX_RENT_VEHICLES>, rID, Float: Position[4], rvstring[128];
- enum rInfo
- {
- rModelID,
- Float: rX,
- Float: rY,
- Float: rZ,
- Float: rA,
- rColor1,
- rColor2,
- rRespawnDelay,
- rPrice,
- rVehicle
- };
- new RentInfo[MAX_RENT_VEHICLES][rInfo];
- /*
- • Function: CreateRentVehicle(modelid, Float: X, Float: Y, Float: Z, Float: A, Color1, Color2, Respawn_Delay, Price)
- • Usage: Creating rent vehicle!
- • Parameters:
- modelid: ID of vehicle
- X, Y, Z, A: position of vehicle
- Color1, Color2: color of vehicle
- Respawn_Delay: respawn delay of vehicle
- Price: price which player must pay when he enter rent vehicle (and every minute)
- • Example: CreateRentVehicle(411, 996.4219,-1856.0022,12.8203,276.0259, 3, 0, 60, 5000);
- */
- stock CreateRentVehicle(modelid, Float: X, Float: Y, Float: Z, Float: A, Color1, Color2, Respawn_Delay, Price)
- {
- RentInfo[rID][rModelID] = modelid;
- RentInfo[rID][rX] = X;
- RentInfo[rID][rY] = Y;
- RentInfo[rID][rZ] = Z;
- RentInfo[rID][rA] = A;
- RentInfo[rID][rColor1] = Color1;
- RentInfo[rID][rColor2] = Color2;
- RentInfo[rID][rRespawnDelay] = Respawn_Delay;
- RentInfo[rID][rPrice] = Price;
- RentInfo[rID][rVehicle] = CreateVehicle(RentInfo[rID][rModelID], RentInfo[rID][rX], RentInfo[rID][rY], RentInfo[rID][rZ], RentInfo[rID][rA], RentInfo[rID][rColor1], RentInfo[rID][rColor2], RentInfo[rID][rRespawnDelay]);
- Iter_Add(RentVehicles, rID);
- rID ++;
- }
- /*
- • Function: DestroyRentVehicle(vehicleid)
- • Usage: Destroying rent vehicle!
- • Parameters:
- vehicleid: ID of vehicle
- • Example: DestroyRentVehicle(1);
- */
- stock DestroyRentVehicle(vehicleid)
- {
- RentInfo[vehicleid][rModelID] = 0;
- RentInfo[vehicleid][rX] = 0;
- RentInfo[vehicleid][rY] = 0;
- RentInfo[vehicleid][rZ] = 0;
- RentInfo[vehicleid][rA] = 0;
- RentInfo[vehicleid][rColor1] = 0;
- RentInfo[vehicleid][rColor2] = 0;
- RentInfo[vehicleid][rRespawnDelay] = 0;
- RentInfo[vehicleid][rPrice] = 0;
- DestroyVehicle(RentInfo[vehicleid][rVehicle]);
- Iter_Remove(RentVehicles, vehicleid);
- }
- /*
- • Function: GetTotalRentVehicles()
- • Usage: Getting total created rent vehicles!
- • Parameters:
- vehicleid: ID of vehicle
- • Example: printf("Total rent vehicles loaded: %d", GetTotalRentVehicle());
- */
- stock GetTotalRentVehicles() return Iter_Count(RentVehicles);
- /*
- • Function: IsRentVehicle(vehicleid)
- • Usage: Checking is vehicle rent vehicle!
- • Parameters:
- vehicleid: ID of vehicle
- • Example: if(IsRentVehicle(1)) printf("Vehicle ID 1 is rent vehicle!");
- */
- stock IsRentVehicle(vehicleid)
- {
- foreach(RentVehicles, rv)
- {
- if(vehicleid == RentInfo[rv][rVehicle]) return 1;
- }
- return 0;
- }
- /*
- • Function: GetRentModelID(vehicleid)
- • Usage: Getting vehicle model of rent vehicle!
- • Parameters:
- vehicleid: ID of vehicle
- • Example: printf("Vehicle model of vehicle ID 1 is: %d", GetRentModelID(1));
- */
- stock GetRentModelID(vehicleid) return RentInfo[vehicleid][rModelID];
- /*
- • Function: GetRentPos(vehicleid, &Float: X, &Float: Y, &Float: Z)
- • Usage: Getting position of rent vehicle!
- • Parameters:
- vehicleid: ID of vehicle
- X, Y, Z: Parameters in which variables will be stored values
- • Example:
- new Float: Position[3];
- GetRentPos(1, Position[0], Position[1], Position[2]);
- printf("X: %f Y: %f Z: %f", Position[0], Position[1], Position[2]);
- */
- stock GetRentPos(vehicleid, &Float: X, &Float: Y, &Float: Z)
- {
- X = RentInfo[vehicleid][rX];
- Y = RentInfo[vehicleid][rY];
- Z = RentInfo[vehicleid][rZ];
- }
- /*
- • Function: GetRentZAngle(vehicleid, &Float: A)
- • Usage: Getting Z angle of rent vehicle!
- • Parameters:
- vehicleid: ID of vehicle
- A: Parameter in which variable will be stored value
- • Example:
- new Float: Position[1];
- GetRentZAngle(1, Position[0]);
- printf("A: %f", Position[0]);
- */
- stock GetRentZAngle(vehicleid, &Float: A)
- {
- A = RentInfo[vehicleid][rA];
- }
- /*
- • Function: GetRentColor(vehicleid, &C1, &C2)
- • Usage: Getting color 1 & color 2 of rent vehicle!
- • Parameters:
- vehicleid: ID of vehicle
- C1, C2: Parameters in which variables will be stored values
- • Example:
- new Float: Color[2];
- GetRentColor(vehicleid, Color[0], Color[1]):
- printf("Color 1: %d Color 2: %d", Color[0], Color[1]);
- */
- stock GetRentColor(vehicleid, &C1, &C2)
- {
- C1 = RentInfo[vehicleid][rColor1];
- C2 = RentInfo[vehicleid][rColor2];
- }
- /*
- • Function: GetRentRespawnDelay(vehicleid)
- • Usage: Getting respawn delay of rent vehicle!
- • Parameters:
- vehicleid: ID of vehicle
- • Example: printf("Respawn Delay: %d", GetRentRespawnDelay(1));
- */
- stock GetRentRespawnDelay(vehicleid) return RentInfo[vehicleid][rRespawnDelay];
- /*
- • Function: GetRentPrice(vehicleid)
- • Usage: Getting price of rent vehicle!
- • Parameters:
- vehicleid: ID of vehicle
- • Example: printf("Price: %d", GetRentPrice(1));
- */
- stock GetRentPrice(vehicleid) return RentInfo[vehicleid][rPrice];
- /*
- • Function: GetPlayerRentID(playerid)
- • Usage: Getting ID of rent vehicle in which is player!
- • Parameters:
- playerid: ID of player
- • Example: printf("ID: %d", GetPlayerRentID(playerid));
- */
- stock GetPlayerRentID(playerid)
- {
- foreach(RentVehicles, rv)
- {
- if(IsPlayerInVehicle(playerid, RentInfo[rv][rVehicle])) return GetPlayerVehicleID(playerid);
- }
- return 0;
- }
- /*
- • Function: IsPlayerInRentVehicle(playerid, vehicleid)
- • Usage: Checking is player in specific rent vehicle!
- • Parameters:
- playerid: ID of player
- vehicleid: ID of vehicle
- • Example: if(IsPlayerInRentVehicle(playerid, 1)) SendClientMessage(playerid, -1, "You are in rent vehicle 1");
- */
- stock IsPlayerInRentVehicle(playerid, vehicleid)
- {
- if(IsPlayerInVehicle(playerid, RentInfo[vehicleid][rVehicle])) return 1;
- return 0;
- }
- /*
- • Function: IsPlayerInAnyRentVehicle(playerid)
- • Usage: Checking is player in any rent vehicle!
- • Parameters:
- playerid: ID of player
- • Example: if(IsPlayerInAnyRentVehicle(playerid)) SendClientMessage(playerid, -1, "You are in some rent vehicle");
- */
- stock IsPlayerInAnyRentVehicle(playerid)
- {
- foreach(RentVehicles, rv)
- {
- if(IsPlayerInVehicle(playerid, RentInfo[rv][rVehicle])) return 1;
- }
- return 0;
- }
- Hook:RC1_OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- if(IsRentVehicle(vehicleid))
- {
- foreach(RentVehicles, rv)
- {
- if(vehicleid == RentInfo[rv][rVehicle])
- {
- if(ispassenger) return 0;
- if(GetPlayerMoney(playerid) < RentInfo[rv][rPrice])
- {
- GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
- SetPlayerPos(playerid, Position[0], Position[1], Position[2]);
- GameTextForPlayer(playerid, "You don't have enough ~r~money~w~!", 5000, 5);
- return 1;
- }
- GivePlayerMoney(playerid, -RentInfo[rv][rPrice]);
- format(rvstring, sizeof(rvstring), "Rent price: -%d", RentInfo[rv][rPrice]);
- SendClientMessage(playerid, -1, rvstring);
- }
- }
- }
- return 1;
- }
- task CheckRentVehicles[60000]()
- {
- foreach(Player, i)
- {
- foreach(RentVehicles, rv)
- {
- if(IsPlayerInVehicle(i, RentInfo[rv][rVehicle]))
- {
- if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
- {
- if(GetPlayerMoney(i) < RentInfo[rv][rPrice])
- {
- RemovePlayerFromVehicle(i);
- GameTextForPlayer(i, "You don't have enough ~r~money~w~!", 5000, 5);
- return 1;
- }
- GivePlayerMoney(i, -RentInfo[rv][rPrice]);
- format(rvstring, sizeof(rvstring), "Rent price: -%d", RentInfo[rv][rPrice]);
- SendClientMessage(i, -1, rvstring);
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement