Old 07-01-2009   #1
Kaufmancab51
Registered User
Newbie Member
 
Join Date: Mar 2009
Posts: 3
Kaufmancab51 is an unknown quantity at this point
Question [VLE]Assigning Commands

Hello there, i was wondering if it was possible to make a command in VLE where a player enters a checkpoint and it will assign them to a random vehicle, e.g a bus driver walks into a marker, and it automatically teleports them next to a bus. How can that be done using VLE?
Kaufmancab51 is offline   Reply With Quote
Old 07-01-2009   #2
[NoN]Bruno
VCO's Q/C Team Member
 
Join Date: Apr 2009
Location: Argentina
Posts: 70
[NoN]Bruno is on a distinguished road[NoN]Bruno is on a distinguished road[NoN]Bruno is on a distinguished road[NoN]Bruno is on a distinguished road
You could do that in a simple VCO Function...
__________________
[NoN]Bruno is offline   Reply With Quote
Old 07-02-2009   #3
Knucis
Registered User
 
Join Date: Mar 2009
Posts: 25
Knucis is on a distinguished roadKnucis is on a distinguished roadKnucis is on a distinguished roadKnucis is on a distinguished road
Well, You need the callback "onPlayerEnterGlobalMarker(PlayerID, MarkerID, MarkerType)" its a VCO Function, but I am sure you can manage it.

just do:
Quote:
function onPlayerEnterGlobalMarker(PlayerID, MarkerID, MarkerType)
if MarkerID == [here your Checkpoint/Corona ID] then
function
return end
end
__________________
Knucis is offline   Reply With Quote
Old 07-03-2009   #4
Kaufmancab51
Registered User
Newbie Member
 
Join Date: Mar 2009
Posts: 3
Kaufmancab51 is an unknown quantity at this point
Im still a noob at this and i can't figure it out. What exactly must i do in plain simple english?
Kaufmancab51 is offline   Reply With Quote
Old 07-05-2009   #5
Mex
Registered User
 
Join Date: Nov 2008
Posts: 44
Mex is on a distinguished roadMex is on a distinguished roadMex is on a distinguished road
Well VLE 1.04 doesn't support the feature to 'do something' when a player/vehicle enters a marker, but 1.05 will have the ability to assign commands to when a player enters a marker.
But even when 1.05 is released, this may still not be possible to do with an ingame command. As there is no command to teleport a player to a random vehicle, but there is a command to teleport a player to a certain vehicle ID.
But this could also be a problem, as vehicle IDs may change when the server restarts.

However this could be done using scripting, as Bruno & Knucis said.

The following code should really be added as a plugin to VLE, but seeing as the plugin system is removed in 1.05, there's not much point.
Instead, we can simply put it in the 'Callbacks.lua' file, located at 'VLE Extensions/'.
So yeah, open that file with notepad (or notepad++ if you have it), and go to the far bottom of the file (line 146)
Put the blinking cursor at the end of the line, and press enter to add a new line, then add all of the code below.
Then look at this line:
if MarkerID == 0 then
change the 0 to the marker ID that you are told after you use /addcp

then save the file, and if the server is running then restart it.

Btw, you will need to update the MarkerID number (currently 0) if the marker ID changes, which may happen when the server restarts.
If you want it to work on all checkpoints in there server, then change this:
if MarkerID == 0 then
to this:
if MarkerType == "CP" then


Here's the code to add:

Code:
function onPlayerEnterGlobalMarker(PlayerID, MarkerID, MarkerType)
	
	if MarkerID == 0 then
		-- step 1 - load all the vehicle IDs from the file into a table
		
		local Path = VLEGetFilePath("Vehicles")
		local a = 1
		local VehicleIDs = {}
		for Line in io.lines(Path) do
			if Line ~= "TOPLINE" then
				VehicleIDs[a] = tonumber(VLEGetToken(Line, 1, " "))
			end
		end
		
		-- step 2 - find a random vehicle ID within the limits of the vehicle IDs in the server
		
		local Pos = random(1, a)
		local VehicleID = VehicleIDs[Pos]
		
		-- step 3 - teleport the player to the random vehicle ID
		
		local X, Y, Z, ZAngle = GetXYInFrontOfVehicle(VehicleID, 3)
		ZAngle = ZAngle + 180
		
		local PlayerVehicleID = getPlayerVehicleID(PlayerID)
		if PlayerVehicleID == 0 then
			setPlayerPos(PlayerID, X, Y, Z)
			setPlayerAngle(PlayerID, ZAngle)
		else
			setVehiclePos(PlayerVehicleID, X, Y, Z)
			setVehicleAngle(PlayerVehicleID, ZAngle)
		end
	end
	
end
Mex is offline   Reply With Quote
Old 07-06-2009   #6
alec
Pro-Servers Dev
 
alec's Avatar
 
Join Date: Apr 2009
Location: Where else?
Posts: 18
alec is on a distinguished roadalec is on a distinguished roadalec is on a distinguished road
I might turn that into a nifty self-contained function, including a check on vehicle name. Usage would go something like:

spawnPlayerToRandomVehicle(PlayerID,VehicleName,Me ssageOnSuccess,MessageOnFail)
MessageOnSuccess would be shown to the player if a free car was found and they were spawned to it.
MessageOnFail would be shown if there were no free cars.

Alternatively someone else could do it for me

Meh, I'll just throw it together.
__________________

alec is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -6. The time now is 10:04 PM.