-
Posts
288 -
Joined
-
Last visited
Everything posted by jingzhi
-
thank you very much
-
Nevermind i had an idea, i will ask you if i got problem later, is that ok?
-
Yes sure , I always start by trying my self, but I just dont know what to use one player enter command and gui shows up to another player
-
Hey its still not working, I made it like you said Server function lockcar ( thePlayer ) local vehicle = getPedOccupiedVehicle ( thePlayer ) if ( vehicle ) then local vehx,vehy,vehz = getElementPosition(vehicle) if isVehicleLocked ( vehicle ) then setVehicleLocked ( vehicle, false ) triggerClientEvent(getRootElement(),"onvehicleunlock",vehicle, vehx,vehy,vehz) outputChatBox("Your "..getVehicleName(vehicle).." have been unlocked", thePlayer,0,255,0) else setVehicleLocked ( vehicle, true ) triggerClientEvent(getRootElement(),"onvehiclelock",vehicle,vehx,vehy,vehz) outputChatBox("Your "..getVehicleName(vehicle).." have been locked", thePlayer,0,255,0) end end end addCommandHandler("lock",lockcar) function unlock(vehicle) setVehicleLocked(vehicle, false) triggerClientEvent(getRootElement(),"onvehicleunlock",vehicle,vehx,vehy,vehz) end addEventHandler("onPlayerVehicleExit",getRootElement(),unlock) Client addEvent("onvehiclelock",true) function playSoundLock() playSound3D("lock.mp3",vehx,vehy,vehz) end addEventHandler("onvehiclelock",getRootElement(),playSoundLock) addEvent("onvehicleunlock",true) function playSoundUnlock() playSound3D("unlock.mp3",vehx,vehy,vehz) end addEventHandler("onvehicleunlock",getRootElement(),playSoundUnlock)
-
Thank you very much, but can you also tell me how to trigger this with the command that mechanic enters? (because mechanic enter /repair and this gui should be showed to
-
Client side addEvent("onvehiclelock",true) function playSoundLock() playSound3D("lock.wav",vehposx,vehposy,vehposz) outputChatBox("playsound") end addEventHandler("onvehiclelock",getRootElement(),playSoundLock) addEvent("onvehicleunlock",true) function playSoundUnlock() playSound3D("unlock.wav",vehposx,vehposy,vehposz) outputChatBox("playsound") end addEventHandler("onvehicleunlock",getRootElement(),playSoundUnlock) Server side function lockcar ( thePlayer ) local vehicle = getPedOccupiedVehicle ( thePlayer ) if ( vehicle ) then vehposx,vehposy,vehposz = getElementPosition(vehicle) if isVehicleLocked ( vehicle ) then setVehicleLocked ( vehicle, false ) triggerClientEvent(getRootElement(),"onvehicleunlock",vehicle) outputChatBox("Your "..getVehicleName(vehicle).." have been unlocked", thePlayer,0,255,0) else setVehicleLocked ( vehicle, true ) triggerClientEvent(getRootElement(),"onvehiclelock",vehicle) outputChatBox("Your "..getVehicleName(vehicle).." have been locked", thePlayer,0,255,0) end end end addCommandHandler("lock",lockcar) function unlock(vehicle) setVehicleLocked(vehicle, false) triggerClientEvent(getRootElement(),"onvehicleunlock",vehicle) end addEventHandler("onPlayerVehicleExit",getRootElement(),unlock) I want to make the vehicle play a 3d sond when its locked/unlocked, but it always says the vector3 of play3dsound is nil, please help
-
A mechanic comes around a car which need a repair while is in the car, so the mechanic types /repair , and then it will calculate the amount of money needed and see if can afford the repair, if yes, then it will out put a chatbox to to ask if the player want the mechanic to repair his vehicle, if types /accept, the vehicle will be fixed and he will pay the mechanic the fee Hope you can help me
-
Thank you very much Ryan, may I ask one more question : "for k,v in ipairs(vehTable) do" what this code means? What does k,v and ipairs means?
-
if getElementSpeed(for id, vehicle in ipairs(getElementsByType("vehicle"))) > 120 I want to make this script to determine if a vehicle has speed above 120 kmh, but getElementByType(vehicle) give me a table, so how should i write this? I am noob and didn't know all these commands and arguments for table yet, so please please explain me in detail, thank you very very much
-
The errors are gone, but it still doesnt work
-
function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function repair(mechanic,command,player) if getPlayerTeam(mechanic) == "Mechanic" then getPlayerFromPartialName(player) == vehicleowner if vehicleowner then local mx,my,mz = getElementPosition(mechanic) local x,y,z = getElementPosition(vehicleowner) if getDistanceBetweenPoints3D(mx,my,mz,x,y,z) < 3 then local getPedVehicle(vehicleowner) == vehicle if vehicle then repairfee = math.floor ( 1200 - getElementHealth(vehicle)) if getPlayerMoney(vehicleowner) >= repairfee then setElementData(vehicleowner,"temp.fixrequest", "yes") outputChatBox("Your repairing request was sent to "..getPlayerName(vehicleowner),mechanic,255,255,0) outputChatBox(mechanic.." wants to repair your vehicle for $ "..repairfee.." type /acceptrepair to accept",vehicleowner,255,255,0) end end end end end end addCommandHandler("repair",repair) function acceptrepair(vehicleowner) if getElementData(vehicleowner,"fixrequest") == "yes" then fixVehicle(vehicle) outputChatBox("Your "..getElementName(vehicle).."have been repaired",vehicleowner,255,255,0) end end Hey guys I wrote this script based on the Useful function "getPlayerFromPartialName" from wiki, but it says there are some errors, here is the errors: unexpected symbol near '==' (line 15) syntax error near '==' (line 20) Thank you!
-
Hey thank you very much but can you put then in the whole script? Because im noob and I am not sure how to put this table thing, thank you again
-
Please help guys
-
Thank you very much, it works But can you also tell me how to make it be able to let player switch between channels?
-
setRadioChannel(0) song = playSound ([url=http://www.181.fm/stream/asx/181-power.asx]http://www.181.fm/stream/asx/181-power.asx[/url], true) Hey guys please help me with this , how can make the script that the radio can be turned on or off by using commands or buttons?(like /radioon, /radiooff) Thank you!
-
Thanks, it works now
-
Thanks, works now
-
It still always say, "you are not in a team" even im in a team
-
Thank you very much , but can you also help me to solve the other 2 problem? What problems? The last script is also not working
-
Thank you very much , but can you also help me to solve the other 2 problem?
-
local marker = createMarker (1510.85327,-1673.48230,13.5, "cylinder",2.5,0,0,255) police = createTeam ("Police",0,0,255) function MarkerHit(hitElement) if getElementType(hitElement) == "player" then setElementModel(hitElement,266) setPlayerTeam (hitElement,police) outputChatBox("You have taken the Police job",hitElement,0,0,255) end end addEventHandler("onMarkerHit",marker,MarkerHit) This part is the police job script function isPlayerInTeam(player, team) assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) end local marker = createMarker(1562.21423,-1607.67883,12.8,"cylinder",1.5,0,0,255) addEventHandler("onMarkerHit",marker, function(thePlayer) if getElementType(thePlayer) =="player" then if (isPedInVehicle(thePlayer)) then return end if (isPlayerInTeam(thePlayer,police)) then local x,y,z = getElementPosition(thePlayer) local veh = createVehicle (509,x,y,z) warpPedIntoVehicle (thePlayer, veh) outputChatBox("You are given a " ..getVehicleName(veh).."" ,thePlayer,0,0,255) else outputChatBox("marker unavailable") end end end) And here is the police spawner script They work, but for the spawner if you are not in "police" team, they still give you a vehicle function teamName(thePlayer) local playerteam = getPlayerTeam(thePlayer) if (playerTeam = true) then outputChatBox("Your team is "..playerTeam.."") else outputChatBox("You are not in a team") end end addCommandHandler("teamname",teamName) And please tell me, why this is not working it always say im not in a team At last, please don't go hard on me, im a noob
-
Thank you so much
-
Sorry for my bad explanation, what i mean is, player will pay for repair depends on how much the car got damaged, for example if its 1% damaged only, then pay 100, 50% damaged pay 500, and so on
-
Another problem pops up, it will still fix the vehicle when nobody is in the car Also, I want to make the player pay for the repair depends on the vehicles HP, again my scripts won't work local marker = createMarker(2064.46924,-1831.39221,12.6, "cylinder",4,255,255,0) addEventHandler("onMarkerHit",marker, function(thePlayer) if getElementType(thePlayer) =="player" and isPedInVehicle( thePlayer ) then local veh = getPedOccupiedVehicle(thePlayer) if (veh) then VehH = math(1000 -getElementHealth(veh) fixVehicle(veh) outputChatBox("Your "..getVehicleName(veh).." was repaired for "..VehH.."$") takePlayerMoney(thePlayer, VehH) end end end) Can you help me out?
-
Another problem pops up, it will still fix the vehicle when nobody is in the car