Продажа WCD (Williams Car Dealer)

Хочется сделать так, чтоб при покупке автодоната выдавался транспорт игроку. Система кардилера - Williams Car Delaer.

Документация

Serverside
hook: WCD::SpawnedVehicle - ply, veh, isEnt - called after player spawned vehicle
hook: WCD::AllowedToSpawnVehicle - ply, WCD ID, vehicle class - return false, msg to prevent

To find a Vehicle ID, simply look in !wcd > Edit vehicle. all vehicles are named as: Display name (#123456).
In this case, 123456 is the id.

To use with a Donation System, there are two choices!
Console Command Actions:
wcd_givevehicle "STEAM_0:1:234567" 123456
wcd_takevehicle "STEAM_0:1:234567" 123456 
Lua functions:
WCD:GiveVehicleToSteamID( "STEAM_0:1:234567", 123456 )
WCD:TakeVehicleFromSteamID( "STEAM_0:1:234567", 123456 )

It depends on your donation system! Usually there's some replacement string like {{ steam_id_32 }}, put this in quotemarks and it will work fine. Like this: wcd_givevehicle "{{ steam_id_32 }}" 123456
These examples would give the user with this SteamID, the vehicle 123456. 

WCD.List[ uniqueId ] contains the vehicle data (always on server, not always on client unless requested via dealer/admin menu)

player meta:
:WCD_GetSpecifics( id ) - returns a table with player's specifics for that id ( { fuel = 10, udnErglow = Color() etc }
:WCD_GetOwned() - returns a table { id = true }
:WCD_GetUnOwned()
:WCD_AddVehicle( id ) - gives player vehicle
:WCD_RemoveVehicle( id )
:WCD_HasAccess( id )
:WCD_AddActiveCar( vehicle ) - this table is checked when spawning a vehicle to see maxSpawned
vehicle meta:
Each has a Set version too
:WCD_GetId() - returns the vehicle's uniqueId
:WCD_GetFuel() - returns the fuel amount
:WCD_GetFuelMax() - returns the max fuel
:WCD_GetNitro() - returns the nitro level

:WCD_GetUnderglow() - get active status
:WCD_GetUnderglowColor() - get color

Не совсем понятно, что нужно сделать, так что сделаем услугу в донате которая будет выдавать автомобиль, и так как уже описано ранее в скрипте нам нужен ID автомобиля его

Чтобы выдавать какой либо автомобиль нам нужен его ID. Чтобы его найти, нужно прописать !wcd и зайти в пункт Edit Vehicle, затем навести мышку на определённую машину и там будет Display name (#айди)

С этим ИД делаем услугу:

IGS("Ford Mustang", "vehfordmustang", 250)
	:SetDescription("При покупке этой услуги данная машина будет доступна у авто продавца")
	:SetCategory("Машины")
	:SetOnActivate(function(pl)
		WCD:GiveVehicleToSteamID(pl:SteamID(), 123456) -- заменить 123456 на ид машины
		-- RunConsoleCommand("wcd_givevehicle " .. pl:SteamID() .. " 123456")
	end)

Путь: addons\igsmodification\lua\igs\settings\sh_additems.lua

Удачи =)

Упростил текст и исправил код

1 лайк

А как сделать чтоб эту машину не могли купить в самом кар диллере? ТОлько в донате