Jump to content

jingzhi

Members
  • Posts

    288
  • Joined

  • Last visited

Everything posted by jingzhi

  1. You can use getElementPosition and getElementRotation, e.g. if you are facing north then -5 in the y of your current position, if you facing south then +5, but you need to find out the trigonometry formula determine how much you add or subtract on the y or x axis. Btw why you need this?
  2. Server side function createguard() local guardped = createPed(281,1544.16125,-1631.99683,13.38281,0,true) triggerClientEvent("giveguardm4",guardped) end addEventHandler("onResourceStart",getRootElement(),createguard) Client side addEvent("giveguardm4",true) function sendguardm4() outputChatBox("client event triggered") guard = source if guard then givePedWeapon(guard,m4,5000,true) end end addEventHandler("giveguardm4",getRootElement(),sendguardm4) function invadeguard(attacker) if attacker and getElementType(attacker) == "player" then local pedhp = getElementHealth (guard) local tarhp = getElementHealth (attacker) if pedhp > 0 and tarhp > 0 then local x,y,z = getElementPosition(guard) local ax,ay,az = getElementPosition(attacker) local isclear = isLineOfSightClear (x,y,z+.6,ax,ay,az+.6, true, false, false, true, false, false, false) if isclear == true then local angle = ( 360 - math.deg ( math.atan2 ( ( ax - x ), ( ay - y ) ) ) ) % 360 if isPedDucked() setPedAimTarget(guard,ax,ay,az-.5) setPedControlState (guard,"fire",true) else setPedAimTarget(guard,ax,ay,az) setPedControlState (guard,"fire",true) end setTimer(invadeguard,50,1,attacker) end end end end addEventHandler("onClientPedDamage",guard,invadeguard) So I want to make this bot for the guard, which if someone attack the guard, guard will shoot him with the m4, but when i try to run this script the guard was not even given a m4, so I put a chatbox and findout the event of giving m4 was not even triggered, please tell me where have I done wrong, and if there is other error please also tell me, thank you very much
  3. ohhh i thought you were a different guy, now i realize ,i have checked your gui, they were really nice, but way too complex for me
  4. function barriernotbreakable() triggerClientEvent("setbarriernotbreakable",root,barrier) end addEventHandler("onResourceStart",resourceRoot,barriernotbreakable) function barriernotbreakableOnJoin() triggerClientEvent(source, "setbarriernotbreakable", root, barrier) end addEventHandler("onPlayerJoin",getRootElement(),barriernotbreakableOnJoin) Thank you very much again , but I did it as you said, but still not working
  5. Again ryan, its you, thank you very very much
  6. You could do something like this; local currentSong = nil; local isSongPaused = false; -- Code and shizzle currentSong = playSound("www.example.com/listen.pls"); -- More code function muteSong_Handler() if(getElementType(currentSong) == "sound") then setSoundPaused(currentSong, not isSongPaused); isSongPaused = (not isSongPaused); else outputChatBox("No radio is currently being streamed!") end end Thank you but i want a GUI panel for this
  7. Hey but in this case "source" is not really the source but is a parameter i passed down by "triggerClientEvent()", and also will what will 30 % 360 give me and -30 % 360 give me? thanks for help
  8. But I got one more problem, I want to set the barrier not breakable using setObejectBreakable(), but its not working, can you help me with this? Server side function barriernotbreakable() triggerClientEvent("setbarriernotbreakable",resourceRoot,barrier) end addEventHandler("onResourceStart",getRootElement(),barriernotbreakable) Client addEvent("setbarriernotbreakable",true) function setbarriernotbreakable(barrier) setObjectBreakable(barrier,false) end addEventHandler("setbarriernotbreakable",getRootElement(),setbarriernotbreakable)
  9. Again, thank you very much for fixing, your explaination was also helpful
  10. I am trying to make a gui for radio, if i choose a radio station from the gridlist and then i press play, it should play the online radio i chose in the gridlist, when i press stop it should stop
  11. addEvent("onPlayerArrested",true) function cuffed(arrester,source) if (isPedInVehicle(source)) then return end local copx, copy, copz = getElementPosition (arrester) local prisonerx, prisonery, prisonerz = getElementPosition (source) copangle = (360 - math.deg (math.atan2 ((copx - prisonerx), (copy - prisonery)))) % 360 setPedRotation(theprisoner, copangle) setCameraTarget(theprisoner, theprisoner) local dist = getDistanceBetweenPoints2D (copx, copy, prisonerx, prisonery) if dist < 2 then setControlState("forwards", false) setControlState("sprint", false ) setTimer (cuffed, 500, 0, arrester, arrestedcriminal ) else setControlState("forwards", true) setControlState("sprint", true ) setTimer ( cuffed, 500, 0, arrester, arrestedcriminal ) end end addEventHandler("onPlayerArrested",getRootElement(),cuffed) I did it like this, but its still not working , by the way what is %360 ?
  12. local barrier = createObject(2920,1544.5996,-1623.9502,13.1,90,0,0) local barriermarker = createMarker(1544.88757,-1627.26501,12.7,"cylinder",8,_,_,_,255) function opengate(barriermarker) moveObject(barrier,3000,1544.5996,-1623.9502,13.2,-90) outputChatBox("true") destroyElement(barriermarker) setTimer(moveObject,7500,1,barrier,2600,1544.5996,-1623.9502,13.1,90) local barriermarker = setTimer(createMarker,11000,1,1544.88757,-1627.26501,12.7,"cylinder",8,_,_,_,0) end addEventHandler("onPlayerMarkerHit",resourceRoot,opengate) function barriernotbreakable() triggerClientEvent("setbarriernotbreakable",resourceRoot,barrier) end addEventHandler("onResourceStart",getRootElement(),barriernotbreakable) Client addEvent("setbarriernotbreakable",true) function setbarriernotbreakable() setObjectBreakable(barrier,false) end addEventHandler("setbarriernotbreakable",resourceRoot,setbarriernotbreakable) If i set the element attached of the eventhandler is getRootElement(), player hit any marker will start this function. If i set the element attached to marker it self, when i hit barrier marker nothing happens. please help
  13. Hey but if i do it this way will it show the text in gridlist?
  14. I haven't tried virbration108 yet but asx is already working
  15. Asx was already working, it has no problem
  16. GUIEditor = { scrollbar = {} } addEventHandler("onClientResourceStart", resourceRoot, function() local screenW, screenH = guiGetScreenSize() RadioSystem = guiCreateWindow((screenW - 525) / 2, (screenH - 385) / 2, 525, 385, "Radio System", false) guiWindowSetSizable(RadioSystem, false) RadioPlay = guiCreateButton(274, 145, 142, 69, "Play", false, RadioSystem) RadioStop = guiCreateButton(274, 267, 142, 69, "Stop", false, RadioSystem) RadioStationList = guiCreateGridList(81, 135, 174, 211, false, RadioSystem) guiGridListAddColumn(RadioStationList, "Radio Stations", 0.9) for i = 1, 2 do guiGridListAddRow(RadioStationList) end radio1 = guiGridListSetItemText(RadioStationList, 0, 1, "Power 181 Hit (Billboard top 40)", false, false) radio2 = guiGridListSetItemText(RadioStationList, 1, 1, "Vibration108(Pop Rock)", false, false) GUIEditor.scrollbar[1] = guiCreateScrollBar(2, 192, 172, 19, true, false, RadioStationList) RadioSystemtext = guiCreateLabel(78, 38, 399, 58, "Radio System", false, RadioSystem) Closeradiowindow = guiCreateButton(225, 346, 75, 29, "Close", false, RadioSystem) guiSetFont(RadioSystemtext, "sa-header") guiSetFont(RadioPlay, "sa-header") guiSetFont(RadioStop, "sa-header") guiSetFont(Closeradiowindow, "clear-normal") guiSetVisible(RadioSystem,false) bindKey("m", "down", showradioGUI ) end) local urlPower181 = "http://www.181.fm/stream/asx/181-power.asx" local urlVibration108 = "http://www.vibration108.ch/listen.pls" function radiostationchoice(button) if (button == "left") then if (source == radio1) then outputChatBox("radio selected") radiourl = urlPower181 elseif (source == radio2) then outputChatBox("radio selected") radiourl = urlVibration108 elseif (source == RadioPlay) then playSound(radiourl) elseif (source == RadioStop) then stopSound(radiourl) elseif (source == Closeradiowindow) then guiSetVisible(RadioSystem,false) showCursor(false) end end end addEventHandler("onClientGUIClick",resourceRoot,radiostationchoice) addEventHandler("onClientGUIClick",resourceRoot,radiostationchoice) addEventHandler("onClientGUIClick",resourceRoot,radiostationchoice) addEventHandler("onClientGUIClick",resourceRoot,radiostationchoice) addEventHandler("onClientGUIClick",resourceRoot,radiostationchoice) function showradioGUI() guiSetVisible(RadioSystem,true) showCursor(true) end Hi so I got this problem with my scirpt, I want to make a GUI with gridlist and buttons, when i choose one item in gridlist and then i press play it will play the radio stream i chose,but this is not working, please help
  17. Client-side addEvent("onPlayerArrested",true) function cuffed(arrester,source) local x,y,z = getElementPosition(arrester) local fx,fy,fz = getElementPosition(arrestedcriminal) local distance = getDistanceBetweenPoints2D(fx,fy,x,y) if distance < 2 then setControlState("forwards", false) setControlState("sprint", false ) setTimer (cuffed, 500, 0, arrester, arrestedcriminal ) return else setControlState("forwards", true) setControlState("sprint", true ) setTimer ( cuffed, 500, 0, arrester, arrestedcriminal ) local X,Y = 0,0 local X = math.abs( x - fx ) local Y = math.abs( y - fy ) local angle = math.deg(math.atan2(X/Y)) if ( x > fx ) and ( y > fy ) then angle = 90 - angle elseif ( x > fx ) and ( y < fy ) then angle = 270 + angle elseif ( x < fx ) and ( y > fy ) then angle = 90 + angle elseif ( x < fx ) and ( y < fy ) then angle = 270 - angle setElementRotation( arrestedcriminal, angle ) end end end addEventHandler("onPlayerArrested",getRootElement(),cuffed) Server-side function arrest(arrester,nightstick) if getPlayerTeam(arrester) == getTeamFromName("Police") or getTeamFromName("Speed Enforcement") then if nightstick == 3 then outputChatBox("weapon value correct") if getPlayerWantedLevel(source) > 0 then arrestedcriminal = source if triggerClientEvent(source,"onPlayerArrested",source,source) == true then outputChatBox("clientside event triggered") end end end end end addEventHandler("onPlayerDamage",getRootElement(),arrest) Hey so I wrote this script for after a player being arrested he is forced to follow the police, but it doesn't work. No error is showed, i tried to use outputchatbox to see i found out the server side seems good, please help me
  18. Actually K and V can be any variable: for cat , dog in pairs (getElementsByType("vehicle")) do for mta , gta in pairs (getElementsByType("vehicle")) do for jingzhi , example in pairs (getElementsByType("vehicle")) do But people use single words, mostly K and V for keys and values, actually we are assigning a name to key part and values part from a table like we usually do: local k = key local v = value ... etc Thank you
  19. Actually K and V can be any variable: for cat , dog in pairs (getElementsByType("vehicle")) do for mta , gta in pairs (getElementsByType("vehicle")) do for jingzhi , example in pairs (getElementsByType("vehicle")) do But people use single words, mostly K and V for keys and values, actually we are assigning a name to key part and values part from a table like we usually do: local k = key local v = value ... etc is "k" representing the variable of the name of one item in the table, and v showing it's value?
×
×
  • Create New...