Jump to content

damien111

Members
  • Posts

    270
  • Joined

  • Last visited

Everything posted by damien111

  1. Now i have a new problem, so i took the comment away from infront of added the end, etc. Now nobody can fish. Yes i set the data using runcode, help me?
  2. Thanks guys, it worked, i took out some of the pointless tuff,
  3. Well i am trying to make a script that checks if a player is in a collison box, and also checks what class they are in, and if they are in the class and the box, it allows the to do the /fish command, which puts the player into a animation, randomly choosing from some times, for a timer, that gives the player random amounts of money for thier fish! I get a argument error for all the events that use the player/source , sucha as givePlayerMoney, setPedAnimation , and getElementData, heres my code, i hope you guys can help me! Server showFishignArea = createRadarArea ( 3122.1650390625, -1563.978515625, 300, 300, 0, 255, 255, 100 ) fishingArea = createColRectangle ( 3122.1650390625, -1563.978515625, 300, 300 ) local fishTimes = { {4000}, {6000}, {8000}, {10000}, {2000}, {12000} } local fishAmount = { {3}, {4}, {5}, {6}, {7} } function unpackTimes() return unpack(fishTimes[math.random(#fishTimes)]) end function unpackAmounts() return unpack(fishAmount[math.random(#fishAmount)]) end function startFishing() local timer = unpackTimes() --if (getElementData(player, "class") == "Fisherman") then if (fishingAllowed) then setPedAnimation ( source, "SWORD", "sword_part") payTimer = setTimer( payPlayer, timer, 0 ) end end addCommandHandler ( "fish", startFishing ) function stopfishing() setPedAnimation(source,false) killTimer(payTimer) end addCommandHandler ( "stopfish", stopfishing ) function payPlayer() local amount = unpackAmounts() givePlayerMoney( source, amount ) resetTimer ( payTimer ) end function hill_Enter ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then fishingAllowed = true end end addEventHandler ( "onColShapeHit", fishingArea, hill_Enter ) function hill_Exit ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then fishingAllowed = false end end addEventHandler ( "onColShapeLeave", fishingArea, hill_Exit )
  4. Thankyou, you didnt understand what i mean , i msorry about that, im sometimes , very, hard to understand , i try to write to many things at once, also! I took this and it helped me make my own script, so thank you
  5. So , I am sorry for all this , but , its not creating the blips or anything anymore, heres my code, i did what you said. local fireLocations = { {2016.54296875, -1641.65234375, 14.112878799438}, {2151.07421875, -1807.9921875, 13.54638671875}, {2500.5302734375, -1759.71484375, 13.546875}, {2480.876953125, -1536.6943359375, 24.189422607422}, {2434.80859375, -1289.4814453125, 25.347854614258}, { 2407.958984375, -1106.970703125, 40.295722961426} } function unpackFires () return unpack ( fireLocations [ math.random ( #fireLocations ) ] ) end function scriptCreateFire(root, cmd) local playerSkin = getElementModel(root) if (playerSkin == 277 or playerSkin == 278 or playerSkin == 279) then destroyElement(fireBlip) setTimer(function(root) local x, y, z = unpackFires() fireBlip = createBlip(x,y,z,20) triggerClientEvent(root, "syncFires", root, x, y, z) end, 10000, 0, root) end end setTimer ( scriptCreateFire, 10000, 0 ) addCommandHandler ( "fire", scriptCreateFire ) function player_Wasted() destroyElement(fireBlip) end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted )
  6. the thing was the fire command was just to test the script, if i removed the command handler, made it just a function and triggered the function with a timer, that was half of the time, and the second timer was the second half, would that work?
  7. Alright, so i had to tweak your code a little bit because of the blip being attached, and i think a few other things. I got everythingn to work but the fires spawning, i dont get any debugerrors so im pretty sure its triggering the event : Client addEvent("syncFires", true) addEventHandler("syncFires", root, function(x, y, z) fire = createFire(x, y, z, 50) fire = createFire(x+2, y, z, 50) fire = createFire(x-2, y, z, 50) fire = createFire(x, y+2, z, 50) fire = createFire(x, y-2, z, 50) end ) Server local fireLocations = { {2016.54296875, -1641.65234375, 14.112878799438}, {2151.07421875, -1807.9921875, 13.54638671875}, {2500.5302734375, -1759.71484375, 13.546875}, {2480.876953125, -1536.6943359375, 24.189422607422}, {2434.80859375, -1289.4814453125, 25.347854614258}, { 2407.958984375, -1106.970703125, 40.295722961426} } function unpackFires () return unpack ( fireLocations [ math.random ( #fireLocations ) ] ) end function scriptCreateFire(player, cmd) local playerSkin = getElementModel(player) if (playerSkin == 277 or playerSkin == 278 or playerSkin == 279) then destroyElement(fireBlip) local x, y, z = unpackFires() triggerClientEvent(root, "syncFires", player, x, y, z) fireBlip = createBlip(x ,y, z, 20) end end setTimer ( scriptCreateFire, 180000, 0 ) addCommandHandler ( "fire", scriptCreateFire ) function player_Wasted() destroyElement(fireBlip) end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted )
  8. Haha yeah i figured that out quite quickly.
  9. Well, what your saying is that the scripting just sets a object on fire, i think what it is suppose to do is create those fires server side, useing guidlines set by client side fires, so i made the server file a client file. But now i get another error, Bad Argument @ 'getElementModel' at line 16. local fireLocations = { {2016.54296875, -1641.65234375, 14.112878799438}, {2151.07421875, -1807.9921875, 13.54638671875}, {2500.5302734375, -1759.71484375, 13.546875}, {2480.876953125, -1536.6943359375, 24.189422607422}, {2434.80859375, -1289.4814453125, 25.347854614258}, { 2407.958984375, -1106.970703125, 40.295722961426} } function unpackFires () return unpack ( fireLocations [ math.random ( #fireLocations ) ] ) end function scriptCreateFire () playerSKin = getElementModel(source) if ( playerSKin == 277 or playerSKin == 278 or playerSKin == 279) then destroyElement ( fireBlip ) local x, y, z = unpackFires() -- retrive the player's position fire = createFire( x, y, z , 20) -- create the fire in the player's position but with x + 5 fireBlip = createBlipAttachedTo ( fire, 20, 2, 0, 0, 0, 255, 0, 9999.0, source ) end end setTimer ( scriptCreateFire, 180000, 0 ) addCommandHandler ( "fire", scriptCreateFire ) function player_Wasted() destroyElement(fireBlip) end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) So yeah, i think i got that figured out, i just need help with that bit , and it should be set, sorry for these questions, i just got back into mta scripting again
  10. As i said ,its not letting me put out the fire.. I cant figure out why. Also there is no onFireExtuinguish event so how can i make something like that , so it pays a fireman per fire
  11. I cant get the script to let the fire be extinguished. I merged my script with the syncfire script. I cant figure out why it wont let the fire be extinguished though. Server local fireLocations = { {2016.54296875, -1641.65234375, 14.112878799438}, {2151.07421875, -1807.9921875, 13.54638671875}, {2500.5302734375, -1759.71484375, 13.546875}, {2480.876953125, -1536.6943359375, 24.189422607422}, {2434.80859375, -1289.4814453125, 25.347854614258}, { 2407.958984375, -1106.970703125, 40.295722961426} } function unpackFires () return unpack ( fireLocations [ math.random ( #fireLocations ) ] ) end function scriptCreateFire ( player, command ) local rob = getElementModel(player) if ( rob == 277 or rob == 278 or rob == 279) then destroyElement ( fireBlip ) local x, y, z = unpackFires() -- retrive the player's position fire = createFire( x, y, z , 20) -- create the fire in the player's position but with x + 5 fireBlip = createBlipAttachedTo ( fire, 20, 2, 0, 0, 0, 255, 0, 9999.0, source ) end end setTimer ( scriptCreateFire, 180000, 0 ) addCommandHandler ( "fire", scriptCreateFire ) function player_Wasted() destroyElement(fireBlip) end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) synced_fire.lua local fireModel = 2023 local fires = {} addEvent("onFireExtinguished",true) addEvent("onFireCreate",true) function createFire(x,y,z) local fireElem = createObject(fireModel,x,y,z) setElementCollisionsEnabled(fireElem,false) local col = createColSphere(x,y,z+1,2) fires[fireElem] = {fireElem,col} addEventHandler("onColShapeHit",col,setFire) return fireElem end function setFire(elem,dim) if not dim then return end if not elem or not isElement(elem) then return end if getElementType(elem) == "player" then setPedOnFire(elem,true) end end function fireExtinguished(fireElem) triggerEvent("onFireExtinguished",source,fireElem) destroyElement(fires[fireElem][1]) destroyElement(fires[fireElem][2]) fires[fireElem] = nil end addEvent("fireExtinguished",true) addEventHandler("fireExtinguished",root,fireExtinguished) synced_fire_c.lua local fireModel = 2023 function applyFire() local fire = engineLoadDFF("fire.dff",1) engineReplaceModel(fire,fireModel) end addEventHandler("onClientResourceStart",resourceRoot,applyFire) function createExtinguisher(wep,_,_,hitX,hitY,hitZ) if wep ~= 42 then return end for k, v in ipairs(getElementsByType("object",resourceRoot)) do if getElementModel(v) == fireModel then local fX,fY,fZ = getElementPosition(v) local dist = getDistanceBetweenPoints2D(hitX,hitY,fX,fY) if dist < 1 then triggerServerEvent("fireExtinguished",localPlayer,v) end end end end addEventHandler("onClientPlayerWeaponFire",localPlayer,createExtinguisher) function enterTruck(veh,seat) if getElementModel(veh) ~= 407 or seat > 0 then return end if not rendering then addEventHandler("onClientRender",root,checkTurret) end end addEventHandler("onClientPlayerVehicleEnter",localPlayer,enterTruck) function exitTruck() if rendering then removeEventHandler("onClientRender",root,checkTurret) end end addEventHandler("onClientPlayerVehicleExit",localPlayer,exitTruck) addEventHandler("onClientPlayerWasted",localPlayer,exitTruck) function checkTurret() if not getKeyState("vehicle_fire") and not getKeyState("vehicle_secondary_fire") then return end outputDebugString("0") local veh = getPedOccupiedVehicle(localPlayer) outputDebugString("1") if not veh then return end outputDebugString("2") local fX,fY,fZ = getElementPosition(veh) outputDebugString("3") local turretPosX,turretPosY = getVehicleTurretPosition(veh) outputDebugString("4") local turretPosX = math.deg(turretPosX) outputDebugString("5") if turretPosX < 0 then turretPosX = turretPosX+360 end outputDebugString("6") local rotX,rotY,rotZ = getVehicleRotation(veh) outputDebugString("7") local turretPosX = turretPosX+rotZ-360 outputDebugString("8") if turretPosX < 0 then turretPosX = turretPosX+360 end outputDebugString("9") local firetruckShape = createColCircle(fX,fY,20) outputDebugString("10") local burningVehicles = getElementsWithinColShape(firetruckShape,"object") outputDebugString("11") for k, v in pairs(burningVehicles) do local bX,bY,bZ = getElementPosition(v) local neededRot = findRotation(fX,fY,bX,bY) outputDebugString(tostring(neededRot)) if turretPosX > neededRot-30 and turretPosX < neededRot+30 then triggerServerEvent("fireExtinguished",localPlayer,v) break end end destroyElement(firetruckShape) end function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t+360 end return t end
  12. That would help , but the marker isnt being created, i dont think, i still applied it though, and tested
  13. it doesnt create the house marker
  14. <meta> <info author="Damien" description="Robber Job" version="1" type="misc"/> <script src="RobberC.lua" type="client"/> <script src="RobberS.lua" type="server"/> </meta>
  15. I just tryed this, didnt work, any other ideas?
  16. I am trying to make a robber script. I made it so it checks if the player has the skin id 29 and if it does it triggers a event which creates a marker to go to to get money, which triggers the house event again, and so forth. I can not see any reasons why it wouldn't work. Thanks in advanced. Heres the code Client local robberHouses = { {-748.70367431641, 741.42608642578, 18.222219467163}, {-745.70367431641, 741.42608642578, 18.222219467163} -- Messi Put coord In This Table pl0x } function unpackRobberHouses () return unpack ( robberHouses [ math.random ( #robberHouses ) ] ) end addEvent ( "createHouse", true ) function createHouses () x, y, z = unpackRobberHouses () robhouseMarker = createMarker ( x, y, z, "cylinder", 3, 255, 51, 102, 85, localPlayer ) robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32, localPlayer ) end addEventHandler ( "createHouse", root, createHouses ) addEventHandler ( "onClientMarkerHit", root, function ( hitElement ) if ( source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then triggerServerEvent ( "payPlayer", localPlayer ) destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) triggerEvent ( "createHouse", localPlayer ) end end ) addEventHandler ( "onResourceStart", getRootElement(), function() local rob = getElementModel ( source ) if rob == 29 then triggerEvent ( "createHouse", localPlayer ) end end) Server addEvent ( "payPlayer", true ) function givePlayerRobPay () money = math.random ( 350, 1020 ) givePlayerMoney ( source, money ) outputChatBox ( "You succesfully robbed $" ..money, source ) end addEventHandler ( "givePlayerPay", root, givePlayerRobPay )
  17. the table ^ Sorry, ill re read it, i always forget to check if events are server or client
  18. I cant seem to figure out why this isnt working. Im not sure if i used the HitElement variable right, but i am not getting any debug errors, heres my code Trucking C job = createMarker ( -701.61175537109, 958.58966064453, 12.401006697608, "cylinder", 5.0, 255, 0, 0, 175 ) locations = { {-748.70367431641, 741.42608642578, 18.222219467163}, {-745.70367431641, 741.42608642578, 18.222219467163} } function getRandomLocation ( ) return unpack ( locations [ math.random ( #locations ) ] ) end function destroyAll() destroyElement(blip) destroyElement(marker) destroyElement(trailer) outputChatBox("Mission Failed") end addEventHandler("onTrailerDetach", getRootElement(), destroyAll) function hitMarker() destroyElement(blip) destroyElement(marker) destroyElement(trailer) setupAssigment() end function setupAssigment(hitElement, matchingDimension) local elementType = getElementType ( hitElement ) if ( elementType == "vehicle" ) then if getElementModel(hitElement) == 515 or getElementModel(hitElement) == 514 or getElementModel(hitElement) == 403 then marker = createMarker ( x, y, z, "cylinder", 5.0, 255, 0, 0, 175 ) x, y, z = getRandomLocation( ) blip = createBlip ( x, y, z, 51, 10, 0, 0, 0, 255 ) vx, vy, vz = getElementPosition(hitElement) trailer = createVehicle ( 435, vx, vy, vz ) -- create a trailer attachTrailerToVehicle ( hitElement, trailer ) -- attach them end end end addEvent( "onMission", true ) addEventHandler( "onMission", getRootElement(), setupAssigment ) Trucker - S addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() truckSkins = { [206]=true, [133]=true } trucks = { [515]=true, [514]=true, [403]=true } end ) function enterVehicle ( thePlayer, seat, jacked ) if ( trucks[getElementModel ( source )] ) and ( not truckSkins[getElementModel ( thePlayer )] ) and (seat == 0) then cancelEvent() outputChatBox ( "Only truckers drivers can drive this", thePlayer ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle )
  19. I cant seem to get this to work, i fixed everything so far except ERROR:ARPGSpawnMenu\SpawnC.lua:215 attempt to index global 'classes' ( a nil value ) I checked and checked and that is something i cant seem to figure out! Thanks in advanced and heres my code SpawnC ------------------------------------------------------------------------------------------------------------------------------------------------------------------ GUIEditor = { button = {}, window = {}, } addEventHandler("onPlayerWasted", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(56, 343, 262, 370, "", false) guiWindowSetSizable(GUIEditor.window[1], false) losSantos = guiCreateButton(10, 40, 243, 44, "Los Santos", false, GUIEditor.window[1]) LV = guiCreateButton(10, 94, 243, 44, "Las Venturas", false, GUIEditor.window[1]) SF = guiCreateButton(10, 148, 243, 44, "San Fierro", false, GUIEditor.window[1]) RC = guiCreateButton(10, 202, 243, 44, "Red County", false, GUIEditor.window[1]) BC = guiCreateButton(10, 256, 243, 44, "Bone County", false, GUIEditor.window[1]) addEventHandler ( "onClientGUIClick", losSantos, showLS, false ) addEventHandler ( "onClientGUIClick", lasVenturas, showLV, false ) addEventHandler ( "onClientGUIClick", sanFierro, showSF, false ) addEventHandler ( "onClientGUIClick", redCounty, showRC, false ) addEventHandler ( "onClientGUIClick", boneCounty, showBC, false ) end ) addEventHandler("onPlayerLogin", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(56, 343, 262, 370, "", false) guiWindowSetSizable(GUIEditor.window[1], false) losSantos = guiCreateButton(10, 40, 243, 44, "Los Santos", false, GUIEditor.window[1]) lasVenturas = guiCreateButton(10, 94, 243, 44, "Las Venturas", false, GUIEditor.window[1]) sanFierro = guiCreateButton(10, 148, 243, 44, "San Fierro", false, GUIEditor.window[1]) redCounty = guiCreateButton(10, 202, 243, 44, "Red County", false, GUIEditor.window[1]) boneCounty = guiCreateButton(10, 256, 243, 44, "Bone County", false, GUIEditor.window[1]) addEventHandler ( "onClientGUIClick", losSantos, showLS, false ) addEventHandler ( "onClientGUIClick", lasVenturas, showLV, false ) addEventHandler ( "onClientGUIClick", sanFierro, showSF, false ) addEventHandler ( "onClientGUIClick", redCounty, showRC, false ) addEventHandler ( "onClientGUIClick", boneCounty, showBC, false ) end ) function showLS() menuState = "LS" end function showLV() menuState = "LV" end function showSF() menuState = "SF" end function showRC() menuState = "RC" end function showBC() menuState = "BC" end ------------------------------------------------------------------------------------------------------------------------------------------------------------------ if menuState == "LS" then classes = { [1]={name="Police", location="Los Santos", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [2]={name="Police", location="Los Santos", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [3]={name="Police", location="Los Santos", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [4]={name="Police", location="Los Santos", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [5]={name="Police", location="Los Santos", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [6]={name="Police", location="Los Santos", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [7]={name="Police", location="Los Santos", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [8]={name="Police", location="Los Santos", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false} } elseif menuState == "LV" then classes = { [1]={name="Police", location="Las Venturas", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [2]={name="Police", location="Las Venturas", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [3]={name="Police", location="Las Venturas", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [4]={name="Police", location="Las Venturas", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [5]={name="Police", location="Las Venturas", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [6]={name="Police", location="Las Venturas", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [7]={name="Police", location="Las Venturas", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [8]={name="Police", location="Las Venturas", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false} } elseif menuState == "SF" then classes = { [1]={name="Police", location="San Fierro", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [2]={name="Police", location="San Fierro", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [3]={name="Police", location="San Fierro", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [4]={name="Police", location="San Fierro", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [5]={name="Police", location="San Fierro", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [6]={name="Police", location="San Fierro", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [7]={name="Police", location="San Fierro", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [8]={name="Police", location="San Fierro", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false} } elseif menuState == "BC" then classes = { [1]={name="Police", location="Bone County", skin=281, r=255, g=255, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [2]={name="Police", location="Bone County", skin=281, r=255, g=255, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [3]={name="Police", location="Bone County", skin=281, r=255, g=255, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [4]={name="Police", location="Bone County", skin=281, r=255, g=255, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [5]={name="Police", location="Bone County", skin=281, r=255, g=255, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [6]={name="Police", location="Bone County", skin=281, r=255, g=255, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [7]={name="Police", location="Bone County", skin=281, r=255, g=255, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [8]={name="Police", location="Bone County", skin=281, r=255, g=255, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false} } elseif menuState == "RC" then classes = { [1]={name="Police", location="Red County", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [2]={name="Police", location="Red County", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [3]={name="Police", location="Red County", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [4]={name="Police", location="Red County", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [5]={name="Police", location="Red County", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [6]={name="Police", location="Red County", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [7]={name="Police", location="Red County", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, [8]={name="Police", location="Red County", skin=281, r=0, g=0, b=255, camx=-2193.1892, camy=609.5613, camz=35.1641, x=-2185.3618, y=609.2630, z=35.1641, rotz=91, locked=false}, } end local weapons = { ["Police"]={3, 24, 23, 25 } } local curr = 1 addEvent("client:showSpawnMenu", true) addEventHandler("client:showSpawnMenu", root, function(class) addEventHandler("onClientRender", root, drawSpawnInfo) bindKey("arrow_l", "down", switchPrevious) bindKey("arrow_r", "down", switchNext) bindKey("space", "down", switchSpawn) bindKey("enter", "down", spawn) updateClassPos(curr) end) function switchSpawn() end function switchNext(_, state) if state == "down" then curr = curr + 1 if curr > #classes then curr = 1 end outputChatBox(classes[curr].name) updateClassPos(curr) end end function switchPrevious(_, state) if state == "down" then curr = curr - 1 if curr < 1 then curr = #classes end outputChatBox(classes[curr].name) updateClassPos(curr) end end function spawn() if classes[curr].locked then if isPlayerInTeam(localPlayer, classes[curr].team) then normalSpawn() else outputChatBox("Only members of '"..classes[curr].team.."' are allowed to use this spawn!", 255, 0, 0) end else normalSpawn() end end function normalSpawn() removeEventHandler("onClientRender", root, drawSpawnInfo) unbindKey("arrow_l", "down", switchPrevious) unbindKey("arrow_r", "down", switchNext) unbindKey("enter", "down", spawn) outputChatBox("Spawned") if isElement(actor) then destroyElement(actor) end triggerServerEvent("server:spawnOptions", localPlayer, classes[curr].skin, weapons[classes[curr].name][1], weapons[classes[curr].name][2], weapons[classes[curr].name][3], weapons[classes[curr].name][4], weapons[classes[curr].name][5], classes[curr].x, classes[curr].y, classes[curr].z, classes[curr].rotz) end function updateClassPos(num) if not isElement(actor) then actor = createPed(classes[num].skin, classes[num].x, classes[num].y, classes[num].z) end local cx, cy, cz = classes[num].camx, classes[num].camy, classes[num].camz setPedRotation(actor, classes[num].rotz) setElementPosition(actor, classes[num].x, classes[num].y, classes[num].z) setElementModel(actor, classes[num].skin) setCameraMatrix(cx, cy, cz, classes[num].x, classes[num].y, classes[num].z) end function isPlayerInTeam(src, TeamName) if src and isElement ( src ) and getElementType ( src ) == "player" then local team = getPlayerTeam(src) if team then if getTeamName(team) == TeamName then return true else return false end end end end function drawSpawnInfo() local x, y, z = classes[curr].x, classes[curr].y, classes[curr].z local sx, sy = getScreenFromWorldPosition(x, y, z) if sx then dxDrawFramedText(classes[curr].name, sx+65, sy-50, 10, 10, tocolor(classes[curr].r, classes[curr].g, classes[curr].b, 255), tocolor(0, 0, 0, 255), 2, "default-bold") dxDrawFramedText(getZoneName(x, y, z, true).." (SPACE to change)", sx+65, sy, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") dxDrawFramedText("Weapons:", sx+65, sy+25, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][1]), sx+65, sy+50, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][2]), sx+65, sy+75, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][3]), sx+65, sy+100, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][4]), sx+65, sy+125, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") dxDrawFramedText("- "..getWeaponNameFromID(weapons[classes[curr].name][5]), sx+65, sy+150, 10, 10, tocolor(255, 255, 255, 255), tocolor(0, 0, 0, 255), 1.5, "default-bold") end end function dxDrawFramedText ( message , left , top , width , height , color , frameColor , scale , font , alignX , alignY , clip , wordBreak , postGUI ) color = color or tocolor ( 255 , 255 , 255 , 255 ) frameColor = frameColor or tocolor ( 0 , 0 , 0 , 255 ) scale = scale or 1 font = font or "default" alignX = alignX or "left" alignY = alignY or "top" clip = clip or false wordBreak = wordBreak or false postGUI = postGUI or false local sMessage = message : gsub ( "#%x%x%x%x%x%x" , "" ) dxDrawText ( sMessage , left + 1 , top + 1 , width + 1 , height + 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) dxDrawText ( sMessage , left + 1 , top - 1 , width + 1 , height - 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) dxDrawText ( sMessage , left - 1 , top + 1 , width - 1 , height + 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) dxDrawText ( sMessage , left - 1 , top - 1 , width - 1 , height - 1 , frameColor , scale , font , alignX , alignY , clip , wordBreak , false ) dxDrawText ( message , left , top , width , height , color , scale , font , alignX , alignY , clip , wordBreak , false ) end SpawnS addEventHandler("onPlayerLogin", root, function() triggerClientEvent ( "client:showSpawnMenu", getRootElement() ) end ) addEventHandler ( "onPlayerWasted", root, function() triggerClientEvent ( "client:showSpawnMenu", getRootElement() ) end ) addEventHandler ( "onPlayerWasted", root, function( ) fadeCamera ( source, false, 1.0, 255, 0, 0 ) -- fade the player's camera to red over a period of 1 second setTimer ( fadeCamera, 500, 1, source, true, 0.5 ) -- don't let it go to opaque red, interrupt it after half a second and fade back to normal end ) local ammo = { [3]={1}, [24]={300}, [23]={300}, [25]={300} } addEvent("server:spawnOptions", true) addEventHandler("server:spawnOptions", root, function(skin, w1, w2, w3, w4, w5, x, y, z, rotz) spawnPlayer(source, x, y, z, rotz, skin) setElementInterior(source, 0) setElementDimension(source, 0) setCameraTarget(source, source) giveWeapon(source, w1, ammo[w1][1]) giveWeapon(source, w2, ammo[w2][1]) giveWeapon(source, w3, ammo[w3][1], true) giveWeapon(source, w4, ammo[w4][1]) giveWeapon(source, w5, ammo[w5][1]) end) Meta <meta> <info author="Damien" name="Spawn" version="2.0" type="script"/> <script src="SpawnS.lua" type="server"/> <script src="SpawnC.lua" type="client"/> </meta>
×
×
  • Create New...