-
Posts
484 -
Joined
-
Last visited
Everything posted by isa_Khamdan
-
Works now is it possible to make this function to work with a command? local timers = {} local objects = {} function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end function D5(vehicle, player) local Speed = getElementSpeed(vehicle,"kmh") if Speed >= 150 then local x,y,z = getElementPosition(vehicle) if isElement(objects[player]) then return end objects[player] = createObject(2780, x, y, z-2, 0, 0, 0) setElementAlpha(objects[player], 0.0) attachElements(objects[player], vehicle, 0, -2, -1) else if isElement(objects[player]) then destroyElement(objects[player]) objects[player] = nil end end end addEventHandler("onVehicleEnter", C, function(thePlayer, seat) if seat == 0 then timers[thePlayer] = setTimer(D5, 1000, 0, source, thePlayer) end end ) addEventHandler("onVehicleExit", C, function(thePlayer, seat) if seat == 0 then if isTimer(timers[source]) then killTimer(timers[source]) timers[source] = nil if isElement(objects[source]) then destroyElement(objects[source]) objects[source] = nil end end end end ) addEventHandler("onPlayerQuit", root, function() if isTimer(timers[source]) then killTimer(timers[source]) timers[source] = nil if isElement(objects[source]) then destroyElement(objects[source]) objects[source] = nil end end end )
-
ohh wait it works but it don't destroy the element when you use the command again?
-
Both codes doesn't work
-
It keep repeating the outputChatbox message and it didn't create the object and attach it to the vehicle
-
Vehicle is not defined, use getPedOccupiedVehicle for define it. It doesn't work , that's the whole code local C = createVehicle ( 547, 2506.1220, -1680.1697, 13.5765 ) setVehiclePaintjob ( C, 2 ) addEventHandler("onResourceStart",resourceRoot, function() setVehicleDamageProof(C,true) addCommandHandler("obj", function () if (source==C) then if ( isElement ( marker ) ) then destroyElement ( marker ); else local x,y,z = getElementPosition(C) local marker = createObject ( 1318, x,y,z+2, 0, 0, 0 ); attachElements (marker,C, 0, 0, 2 ); end else outputChatBox("You need to be in a vehicle to do this.", source); end end );
-
Hello , I want your help to edit this code to make it start with a command not automatically else I want it that if you type the command again and the object is already created it will destroy it -- createObject local x,y,z = getElementPosition(Vehicle) local marker = createObject ( 1318, x,y,z+2, 0, 0, 0 ) addEventHandler("onVehicleStartEnter",resourceRoot, function () attachElements (marker,Vehicle,0,0,2) end )
-
Never mind I fixed it
-
No I want the same element to be replaced with the new one
-
I don't want to destroy the element just replace it like how the admin givevehicle option works
-
I fixed it thanks for everyone who helped me Edit : how can I replace the player vehicle with the new created vehicle just like the givevehicle on admin panel? function createMyVehicle(vehicleid,x,y,z,thePlayer) if vehicleid and x and y and z then local Vehicle = createVehicle(vehicleid,x,y,z) if thePlayer and Vehicle then warpPedIntoVehicle ( thePlayer, Vehicle ) end end end addEvent("createVehicleFromGUI",true) addEventHandler("createVehicleFromGUI",root,createMyVehicle)
-
The whole script work and I am able to create the vehicles but I want it to warp the ped to the vehicle when it's created.
-
PCSgridlist = guiCreateGridList(10, 54, 197, 238, false, windowPCS) guiGridListAddColumn(PCSgridlist,"Vehicle",0.2) guiGridListAddColumn(PCSgridlist,"Type",0.2) guiGridListSetColumnWidth(PCSgridlist,1,0.4,true) guiGridListSetColumnWidth(PCSgridlist,2,0.5,true) populateGridlist() function populateGridlist() for name,vehicle in pairs(PCSTable) do local row = guiGridListAddRow(PCSgridlist) guiGridListSetItemText(PCSgridlist,row,1,name,false,false) guiGridListSetItemText(PCSgridlist,row,2,getVehicleType(vehicle),false,false) guiGridListSetItemData(PCSgridlist,row,1,tostring(vehicle)) end end
-
Now it say nill and invalid argument
-
No errors in the debugscript 3 the client side is made to output this message if there is a mistake
-
It Doesn't work I can't spawn the vehicle Edit : it says invalid augment
-
I don't type them on the client side there is a code that get them onguiclock
-
Anyone know how can I fix it?
-
Pointless what you did there. Since its a command its suppose have; function (player, command, vehicleId, x, y, z) I tested it but it didn't work Client side function createVehicleHandler(button,state) if button == "left" and state == "up" then local row,col = guiGridListGetSelectedItem(PCSgridlist) if row and col and row ~= -1 and col ~= -1 then local selected = guiGridListGetItemData(PCSgridlist,row,col) selected = tonumber(selected) local rotz = getPedRotation(getLocalPlayer()) local x,y,z = getElementPosition(getLocalPlayer()) x = x y = y if selected and x and y and z then triggerServerEvent("createVehicleFromGUI",getRootElement(),selected,x,y,z) guiSetVisible(windowPCS,false) showCursor(false,false) else outputChatBox("Invalid arguments.") end else outputChatBox("Please select a vehicle.") end end end Server side function createMyVehicle(thePlayer,vehicleid,x,y,z) -- check all the arguments exist if vehicleid and x and y and z then local Vehicle = createVehicle(vehicleid,x,y,z) warpPedIntoVehicle ( thePlayer, Vehicle ) end end addEvent("createVehicleFromGUI",true) addEventHandler("createVehicleFromGUI",root,createMyVehicle)
-
is this code correct? function createMyVehicle(vehicleid,x,y,z) -- check all the arguments exist if vehicleid and x and y and z then local Vehicle = createVehicle(vehicleid,x,y,z) warpPedIntoVehicle ( source, Vehicle ) end end
-
is it possible to use GiveVehicle without admin panel? like using it with command or something?
-
Never mind I found out to do it thanks anyway you helped me a lot
-
What do you mean by "use it as a command"? Nexus is my account name and I use it as a command to spawn my private car so I want the executecommand handler to always use player name as a command executeCommandHandler( "Here is the player name", source )
-
Hmm I am getting one problem now this script works 100% now but only for me because it say my name as a command how can I make it get the player name and use it as a command addEvent("Spawn",true) addEventHandler("Spawn",root, function() local account = getPlayerAccount(source) -- get account element from player element local accname = getAccountName(account) -- get account name from account element if isObjectInACLGroup("user."..accname,aclGetGroup("PCS")) then executeCommandHandler( "Nexus", source ) end end ) in this line " executeCommandHandler( "Nexus", source ) " I want to replace Nexus with player name so anyone click the gui button it will place his name as a command
-
This will do the command when I click the gui button? Finally someone understanded what I wanted thanks a lot man