Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Taxi Job #172

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions accounts/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ AddEvent("OnPlayerSteamAuth", OnPlayerSteamAuth)

function OnPlayerQuit(player)
PlayerData[player].is_online = 0
if PlayerData[player].job == "taxi" or PlayerData[player].job == "delivery" then
GalaxHD551 marked this conversation as resolved.
Show resolved Hide resolved
PlayerData[player].job = ""
end
SavePlayerAccount(player)
GatheringCleanPlayerActions(player)-- → Gathering
DestroyPlayerData(player)
Expand Down Expand Up @@ -107,7 +110,7 @@ function OnAccountCheckIpBan(player)
end

function CreatePlayerAccount(player)
local query = mariadb_prepare(sql, "INSERT INTO `accounts` (`id`, `steamid`, `name`, `clothing`, `police`, `medic`, `inventory`, `position`, `admin`, `health`, `armor`, `thirst`, `hunger`, `bank_balance`, `created`, `phone_number`, `driver_license`, `gun_license`, `helicopter_license`, `drug_knowledge`, `job`, `is_cuffed`, `age`) VALUES (NULL, '?', 'Unregistered', '[]', '0', '0', '[]', '[]', '0', '100', '0', '100', '100', '4900', '0', NULL, '0', '0', '0', '[]', NULL, '0', '0');",
local query = mariadb_prepare(sql, "INSERT INTO `accounts` (`id`, `steamid`, `name`, `clothing`, `police`, `medic`, `inventory`, `position`, `admin`, `health`, `armor`, `thirst`, `hunger`, `bank_balance`, `created`, `phone_number`, `driver_license`, `gun_license`, `helicopter_license`, `taxi_license`, `drug_knowledge`, `job`, `is_cuffed`, `age`) VALUES (NULL, '?', 'Unregistered', '[]', '0', '0', '[]', '[]', '0', '100', '0', '100', '100', '4900', '0', NULL, '0', '0', '0', '0', '[]', NULL, '0', '0');",
tostring(GetPlayerSteamId(player)))

mariadb_query(sql, query, OnAccountCreated, player)
Expand Down Expand Up @@ -155,7 +158,8 @@ function OnAccountLoaded(player)
PlayerData[player].driver_license = math.tointeger(result['driver_license'])
PlayerData[player].gun_license = math.tointeger(result['gun_license'])
PlayerData[player].helicopter_license = math.tointeger(result['helicopter_license'])
PlayerData[player].inventory = json_decode(result['inventory'])
PlayerData[player].taxi_license = math.tointeger(result['taxi_license'])
PlayerData[player].inventory = json_decode(result['inventory'])
PlayerData[player].created = math.tointeger(result['created'])
PlayerData[player].position = json_decode(result['position'])
PlayerData[player].drug_knowledge = json_decode(result['drug_knowledge'])
Expand Down Expand Up @@ -304,6 +308,7 @@ function CreatePlayerData(player)
PlayerData[player].driver_license = 0
PlayerData[player].gun_license = 0
PlayerData[player].helicopter_license = 0
PlayerData[player].taxi_license = 0
PlayerData[player].logged_in = false
PlayerData[player].admin = 0
PlayerData[player].created = 0
Expand Down Expand Up @@ -331,11 +336,11 @@ function DestroyPlayerData(player)
return
end

-- if PlayerData[player].job_vehicle ~= nil then
-- DestroyVehicle(PlayerData[player].job_vehicle)
-- DestroyVehicleData(PlayerData[player].job_vehicle)
-- PlayerData[player].job_vehicle = nil
-- end
--if PlayerData[player].job_vehicle ~= nil then
--DestroyVehicle(PlayerData[player].job_vehicle)
--DestroyVehicleData(PlayerData[player].job_vehicle)
--PlayerData[player].job_vehicle = nil
--end

local attachedObjects = { "backpack", "mask_1", "mask_2", "mask_3", "mask_4" }

Expand All @@ -346,7 +351,6 @@ function DestroyPlayerData(player)
end
end

print("Player disconnected : " .. PlayerData[player].accountid)
PlayerData[player] = nil
print("Data destroyed for : " .. player)
end
Expand All @@ -366,7 +370,7 @@ function SavePlayerAccount(player)
local x, y, z = GetPlayerLocation(player)
PlayerData[player].position = {x = x, y = y, z = z}

local query = mariadb_prepare(sql, "UPDATE accounts SET admin = ?, bank_balance = ?, health = ?, armor = ?, hunger = ?, thirst = ?, name = '?', clothing = '?', inventory = '?', created = '?', position = '?', driver_license = ?, gun_license = ?, helicopter_license = ?, drug_knowledge = '?', job = '?', is_cuffed = ?, age = ?, is_online = '?' WHERE id = ? LIMIT 1;",
local query = mariadb_prepare(sql, "UPDATE accounts SET admin = ?, bank_balance = ?, health = ?, armor = ?, hunger = ?, thirst = ?, name = '?', clothing = '?', inventory = '?', created = '?', position = '?', driver_license = ?, gun_license = ?, helicopter_license = ?, taxi_license = ?, drug_knowledge = '?', job = '?', is_cuffed = ?, age = ?, is_online = '?' WHERE id = ? LIMIT 1;",
PlayerData[player].admin,
PlayerData[player].bank_balance,
PlayerData[player].health,
Expand All @@ -381,6 +385,7 @@ function SavePlayerAccount(player)
PlayerData[player].driver_license,
PlayerData[player].gun_license,
PlayerData[player].helicopter_license,
PlayerData[player].taxi_license,
json_encode(PlayerData[player].drug_knowledge),
PlayerData[player].job or "",
PlayerData[player].is_cuffed or 0,
Expand Down
35 changes: 33 additions & 2 deletions callouts/c_callouts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local _ = function(k, ...) return ImportPackage("i18n").t(GetPackageName(), k, .

local wpObject
local currentCallout
local wplocation = {}

local calloutsUI = nil

Expand Down Expand Up @@ -78,6 +79,16 @@ function CloseCallout(player)
end
AddEvent("callouts:ui:close", CloseCallout)

AddRemoteEvent("callouts:createtaxiwp", function(x, y, z, label)
taxiwp = CreateWaypoint(x, y, z, tostring(label))
GetPickupStaticMeshComponent(pickup):SetHiddenInGame(true)
Delay(360000, function()
if taxiwp ~= nil then
DestroyWaypoint(taxiwp)
end
end)
end)

AddRemoteEvent("callouts:createwp", function(target, x, y, z, label)
if wpObject ~= nil then DestroyWaypoint(wpObject) end
currentCallout = target
Expand All @@ -90,6 +101,26 @@ AddRemoteEvent("callouts:cleanwp", function()
currentCallout = nil
if wpObject ~= nil then DestroyWaypoint(wpObject) end
wpObject = nil

CallEvent("ClearCalloutDestination")
end)
end)

-- TAXI WAYPOINT

AddRemoteEvent("DestroyTaxiWP", function(pickup)
local px, py, pz = GetPickupLocation(pickup)
for k, v in pairs(GetAllWaypoints()) do
local wx, wy, wz = GetWaypointLocation(v)
local distance = GetDistance3D(px, py, pz, wx, wy, wz)
if distance < 30 then
DestroyWaypoint(v)
CallRemoteEvent("DestroyPickup", pickup)
break
end
end
end)

AddEvent("OnPickupStreamIn", function(pickup)
if GetPickupPropertyValue(pickup, "TaxiCall") then
GetPickupStaticMeshComponent(pickup):SetHiddenInGame(true)
end
end)
70 changes: 68 additions & 2 deletions callouts/s_callouts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ AddCommand("911", function(player, label)
CreateCallout(player, "police", tostring(label))
end)

AddCommand("taxi", function(player, label)
CreateCallout(player, "taxi", tostring(label))
end)

--------- CALLOUTS
AddCommand("clearcallouts", function(player)
Expand All @@ -29,6 +32,8 @@ function CreateCallout(player, job, label)-- create a new callout
caller_job = 'police'
elseif PlayerData[player].job == "medic" then
caller_job = 'medic'
elseif PlayerData[player].job == "taxi" then
caller_job = 'taxi'
end

callOuts[player] = { location = {x = x, y = y, z = z}, taken = false, job = job, label = label, caller_job = caller_job }
Expand All @@ -39,6 +44,9 @@ function CreateCallout(player, job, label)-- create a new callout
CallRemoteEvent(player, "MakeNotification", _("medic_callout_created"), "linear-gradient(to right, #00b09b, #96c93d)", 10000)
elseif job == "police" then
CallRemoteEvent(player, "MakeNotification", _("police_callout_created"), "linear-gradient(to right, #00b09b, #96c93d)", 10000)
elseif job == "taxi" then
CallRemoteEvent(player, "MakeNotification", _("taxi_callout_created"), "linear-gradient(to right, #00b09b, #96c93d)", 10000)
SendGPStoTaxi(player, callOuts[player])
else
CallRemoteEvent(player, "MakeNotification", _("callout_created"), "linear-gradient(to right, #00b09b, #96c93d)", 10000)
end
Expand All @@ -54,13 +62,46 @@ function CalloutsNotifyPlayers(callout)-- send the new callout to medics and pol
elseif callout.job == "police" then
CallRemoteEvent(v, "MakeNotification", _("police_new_callout", callout.label), "linear-gradient(to right, #00b09b, #96c93d)", 10000)
CallRemoteEvent(v, "medic:deathalarm")
else
else
CallRemoteEvent(v, "MakeNotification", _("new_callout", callout.label), "linear-gradient(to right, #00b09b, #96c93d)", 10000)
end
end
end
end

function SendGPStoTaxi(player, callout)
local target = player
label = _("taxi_waypoint_label")
if GetPlayerPropertyValue(target, "Caller") ~= nil then
DPickup = GetPlayerPropertyValue(target, "Caller")
if IsValidPickup(DPickup) then
current_call = true
end
end
local TaxiPickup = CreatePickup(336, callOuts[tonumber(target)].location.x, callOuts[tonumber(target)].location.y, callOuts[tonumber(target)].location.z)
SetPickupScale(TaxiPickup, 40, 40, 4)
SetPickupPropertyValue(TaxiPickup, "TaxiCall", true, true)
SetPlayerPropertyValue(target, "Caller", TaxiPickup, true)
for k, v in pairs(GetAllPlayers()) do
if PlayerData[v] ~= nil and PlayerData[v].job ~= nil and PlayerData[v].job ~= "" and callout.job == PlayerData[v].job then
if callout.job == "taxi" then
if current_call then
CallRemoteEvent(v, "DestroyTaxiWP", DPickup)
end
CallRemoteEvent(v, "medic:deathalarm")
CallRemoteEvent(v, "callouts:createtaxiwp", callOuts[tonumber(target)].location.x, callOuts[tonumber(target)].location.y, callOuts[tonumber(target)].location.z, label)
end
end
end

Delay(360000, function()
if TaxiPickup ~= nil then
DestroyPickup(TaxiPickup)
SetPlayerPropertyValue(target, "Caller", nil, true)
end
end)
end

function CalloutTake(player, target)-- allow to take the callout
if PlayerData[player].job ~= "medic" and PlayerData[player].job ~= "police" then return end
if callOuts[tonumber(target)] == nil then return end
Expand Down Expand Up @@ -163,4 +204,29 @@ function GetCalloutsList(player)
return calloutsList
end

--------- CALLOUTS END
--------- CALLOUTS END

AddEvent("OnPlayerPickupHit", function(player, pickup) -- Destroy pickup
if GetPickupPropertyValue(pickup, "TaxiCall") then
if PlayerData[player].job ~= "taxi" then return end
local vehicle = GetPlayerVehicle(player)
if vehicle == nil then return end
local seat = GetPlayerVehicleSeat(player)
if vehicle == PlayerData[player].job_vehicle and
VehicleData[vehicle].owner == PlayerData[player].accountid and
seat == 1
then
for k, v in pairs(GetAllPlayers()) do
if PlayerData[v] ~= nil and PlayerData[v].job == "taxi" then
CallRemoteEvent(v, "DestroyTaxiWP", pickup)
end
end
end
end
end)

AddRemoteEvent("DestroyPickup", function(player, pickup)
if pickup ~= nil and IsValidPickup(pickup) then
DestroyPickup(pickup)
end
end)
30 changes: 29 additions & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -595,5 +595,33 @@
"item_menu": "Objects menu",
"admin_give_item_success": "Objects given with succes",
"admin_give_item_fail": "Can't give this objects",
"orange": "orange"
"orange": "orange",
"taxi_job": "Chauffeur de taxi",
"taxi_menu": "Menu Taxi",
"taxi_garage_menu": "Garage taxi",
"spawn_taxi_car": "Sortir un taxi",
"quit_taxi": "Vous n'êtes plus chauffeur de taxi",
"taxi_npc_message_stop": "Quoi ?! Tu veux déjà nous quitter ?",
"taxi_npc_message_start": "Bonjour, tu souhaites devenir chauffeur de taxi ?",
"taxi_npc_name": "Mr. White, Employeur",
"taxi_service_npc_starting": "C'est d'accord, bienvenue dans l'équipe",
"taxi_service_npc_end": "Compris, reviens quand tu veux",
"join_taxi": "Vous êtes devenus chauffeur de taxi",
"not_taxi": "Vous n'êtes pas chauffeur de taxi",
"taxi_license": "License de taxi",
"start_course": "Commencer une course",
"end_course": "Terminer une course",
"payement": "Payement",
"payement menu": "Payement Menu",
"payin_cash": "Player pay in cash",
"payin_bank": "Player pay with bank",
"cash_taxi": "Payment in cash : Payment need to be made from your inventory",
"process_pay": "La course est terminée. Veuillez procéder au paiement",
"no_player_in_vehicle": "Il n'y a personne dans votre vehicule !",
"not_in_vehicle": "Vous devez être dans votre vehicule !",
"not_driver": "Vous devez être au volant du vehicule !",
"pay_success": "La transaction a été effectué avec succes",
"no_current_course": "Il n'y a pas de course en cours !",
"taxi_callout_created": "Taxis receive your call",
"taxi_waypoint_label": "Taxi"
}
32 changes: 30 additions & 2 deletions i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -644,5 +644,33 @@
"gris_fonce": "Gris foncé",
"gris_titanium": "Gris Titanium",
"violet_fonce": "Violet foncé",
"disable_dev_mode": "Merci de désactiver le DEVMODE dans votre launcher Steam pour jouer sur ce serveur."
}
"disable_dev_mode": "Merci de désactiver le DEVMODE dans votre launcher Steam pour jouer sur ce serveur.",
"taxi_job": "Chauffeur de taxi",
"taxi_menu": "Menu Taxi",
"taxi_garage_menu": "Garage taxi",
"spawn_taxi_car": "Sortir un taxi",
"quit_taxi": "Vous n'êtes plus chauffeur de taxi",
"taxi_npc_message_stop": "Quoi ?! Tu veux déjà nous quitter ?",
"taxi_npc_message_start": "Bonjour, tu souhaites devenir chauffeur de taxi ?",
"taxi_npc_name": "Mr. White, Employeur",
"taxi_service_npc_starting": "C'est d'accord, bienvenue dans l'équipe",
"taxi_service_npc_end": "Compris, reviens quand tu veux",
"join_taxi": "Vous êtes devenus chauffeur de taxi",
"not_taxi": "Vous n'êtes pas chauffeur de taxi",
"taxi_license": "License de taxi",
"start_course": "Commencer une course",
"end_course": "Terminer une course",
"payement": "Paiement",
"payement menu": "Menu Paiement",
"payin_cash": "Paiement en liquide",
"payin_bank": "Paiment avec la banque",
"cash_taxi": "Paiement en liquide : La transaction doit être réalisée depuis vos inventaires",
"process_pay": "La course est terminée. Veuillez procéder au paiement",
"no_player_in_vehicle": "Il n'y a personne dans votre vehicule !",
"not_in_vehicle": "Vous devez être dans votre vehicule !",
"not_driver": "Vous devez être au volant du vehicule !",
"pay_success": "La transaction a été effectué avec succes",
"no_current_course": "Il n'y a pas de course en cours !",
"taxi_callout_created": "Les taxis ont reçu votre appels",
"taxi_waypoint_label": "Taxi"
}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"admin/s_spectate.lua",
"searchobject/server.lua",
"callouts/s_callouts.lua",
"onset-characterize/server.lua"
"onset-characterize/server.lua",
"taxi/s_taxi.lua"
],
"client_scripts": [
"welcome/client.lua",
Expand Down Expand Up @@ -93,7 +94,8 @@
"admin/c_spectate.lua",
"searchobject/client.lua",
"callouts/c_callouts.lua",
"onset-characterize/client.lua"
"onset-characterize/client.lua",
"taxi/c_taxi.lua"
],
"files": [
"hud/speaking/speaking.png",
Expand Down Expand Up @@ -240,6 +242,7 @@
"onset-characterize/ui/jquery.js",
"onset-characterize/ui/style.css",
"onset-characterize/click.wav",
"admin/broadcastui/broadcastui.html"
"admin/broadcastui/broadcastui.html",
"taxi/taxihud.html"
]
}
1 change: 1 addition & 0 deletions roleplay.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CREATE TABLE IF NOT EXISTS `accounts` (
`driver_license` tinyint(1) NOT NULL DEFAULT '0',
`gun_license` tinyint(1) NOT NULL DEFAULT '0',
`helicopter_license` tinyint(1) NOT NULL DEFAULT '0',
`taxi_license` tinyint(1) NOT NULL DEFAULT '0',
`drug_knowledge` text NOT NULL,
`job` varchar(20) DEFAULT NULL,
`is_cuffed` tinyint(1) NOT NULL DEFAULT '0',
Expand Down
Loading