Jump to content

LLCoolJ

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by LLCoolJ

  1. LLCoolJ

    Help me

    local x,y = guiGetScreenSize() addEventHandler("onClientResourceStart", resourceRoot,function() weaponWindow = guiCreateWindow((x/2)-(256/2),(y/2)-(398/2), 256, 382, "weapon",false) guiWindowSetSizable(weaponWindow, false) weaponGrid = guiCreateGridList(16, 30, 226, 337,false,weaponWindow) guiGridListAddColumn(weaponGrid, "Inventory", 0.9) guiSetVisible (weaponWindow, false ) toggleControl ( "next_weapon", false) toggleControl ( "previous_weapon", false) guiGridListSetSortingEnabled ( weaponGrid, false ) addEventHandler("onClientGUIDoubleClick",weaponWindow,selectWeapon) end) addEventHandler("onClientResourceStop", resourceRoot,function() toggleControl ( "next_weapon", true) toggleControl ( "previous_weapon", true) end) bindKey("k","down", function() guiSetVisible(weaponWindow,not guiGetVisible(weaponWindow)) showCursor(guiGetVisible(weaponWindow)) refreshWeapons() end) function refreshWeapons() guiGridListClear(weaponGrid) for i=1,9 do local weapon = getPedWeapon(localPlayer,i) if weapon and weapon ~= 0 then guiGridListAddRow(weaponGrid) guiGridListSetItemText(weaponGrid,guiGridListAddRow(weaponGrid),1,getWeaponNameFromID(weapon),false,false) end end end function selectWeapon() local row,col = guiGridListGetSelectedItem(weaponGrid) local text = guiGridListGetItemText(weaponGrid,row,col) if text ~= "" then setPedWeaponSlot(localPlayer,getSlotFromWeapon(getWeaponIDFromName(text))) end end
  2. Your code works.Are you sure that you have attached elements to vehicle? addCommandHandler("ivi",function() det = getAttachedElements(getPedOccupiedVehicle(localPlayer)) if #det > 0 then for k,v in ipairs(det) do outputDebugString(tostring(v)) end else outputChatBox("no elements were attached") end end) or addCommandHandler("ivi",function() det = getAttachedElements(getPedOccupiedVehicle(localPlayer)) iprint(det) end)
  3. bindKey("F2", "down", function() showCursor(guiSetVisible(Ventana,not guiGetVisible(Ventana)) and guiGetVisible(Ventana)) end)
  4. LLCoolJ

    Trunk open

    local ms = 1000 addCommandHandler("trunk", function(player) local vehicle = getPedOccupiedVehicle(player) if isElement(vehicle) and getElementModel(vehicle) == 541 then if getVehicleDoorOpenRatio(vehicle,1) > 0 then setVehicleDoorOpenRatio(vehicle,1,0,ms) else setVehicleDoorOpenRatio(vehicle,1,1,ms) end end end) Use getElementModel
  5. LLCoolJ

    Trunk open

    local ms = 1000 addCommandHandler("trunk", function(player) local vehicle = getPedOccupiedVehicle(player) if isElement(vehicle) then if getVehicleDoorOpenRatio(vehicle,1) > 0 then setVehicleDoorOpenRatio(vehicle,1,0,ms) else setVehicleDoorOpenRatio(vehicle,1,1,ms) end end end) Server side
  6. function getAllPlayerInDimension(dimension) local rValue = {} for i,v in ipairs(getElementsByType("player")) do if ( getElementDimension ( v ) == dimension ) then table.insert(rValue,getPlayerName(v)) end end return rValue end function SetDimensionLobby() outputChatBox("all players in Dimension 0:"..table.concat(getAllPlayerInDimension(0),",")) end addCommandHandler ("s",SetDimensionLobby)
  7. local AFK = {} function getAFKTableSize(t) local count = 0 if t and type(t) == "table" then for k in next,t do if isElement(k) then count = count + 1 end end end return count end function playerDataChanges(data) if data == "afk_state" then local value = getElementData(source,data) if value == "afk" then if getAFKTableSize(AFK) == 0 then addEventHandler("onClientRender",root,Render) end AFK[source] = true elseif value == "back" then AFK[source] = nil if getAFKTableSize(AFK) == 0 then removeEventHandler("onClientRender",root,Render) end end end end addEventHandler("onClientElementDataChange",root,playerDataChanges) function Render() for player in next,AFK do if isElement(player) then local myPos = {getElementPosition(localPlayer)} local head = {getPedBonePosition(player,8)} if getDistanceBetweenPoints3D(myPos[1],myPos[2],myPos[3],head[1],head[2],head[3]) <= 30 then local x,y = getScreenFromWorldPosition(head[1],head[2],head[3]+0.3) if x and y then dxDrawText("AFK",x,y,x,y,tocolor(255,255,255,255),2,"sans","center","center") end end end end end Client side
  8. addEventHandler("onClientRender",getRootElement(),function() local px,py,pz,tx,ty,tz,dist px,py,pz = getCameraMatrix() for id,player in ipairs(getElementsByType("player")) do tx,ty,tz = getElementPosition(player) dist = math.sqrt((px-tx)^2 + (py-ty)^2 + (pz-tz)^2) if dist <= 30.0 then if isLineOfSightClear(px,py,pz,tx,ty,tz,true,false,false,true,false,false,true) then local sx,sy,sz = getPedBonePosition(player,5) local x,y = getScreenFromWorldPosition(sx,sy,sz+0.3) if x then dxDrawText(getPlayerName(player),x,y,x,y,tocolor(150,50,0),0.85+(15-dist)*0.02,"default-bold","center","center") end end end end end)
  9. 'onClientPlayerJoin' event will trigger for all players except the local player.You need to use 'onClientResourceStart'. Try this local x,y = guiGetScreenSize() local image addEventHandler("onClientResourceStart",resourceRoot, function() image = guiCreateStaticImage(x/2-400/2,y/2-400/2,400,400,"hello.png",false) end) Also add this line to your resource's meta.xml.It means that resource will be started earlier than other resources. <download_priority_group>1</download_priority_group>
  10. function JoinVehicleCar (player, seat) local acc = getAccountName(getPlayerAccount(player)) if seat == 0 then if (getVehicleType(source) == "Automobile" or getVehicleType(source) == "Bike") then if not (isObjectInACLGroup("user."..acc, aclGetGroup("HABCARMOTO"))) then cancelEvent() return outputChatBox("#000000[ #FFFF00CNH#000000 ] #FFFFFFVocê não possui #ff0000Habilitação #ffffff para conduzir este veiculo!",player,255,255,255, true) end end if (getVehicleType(source) == "Helicopter" or getVehicleType(source) == "Plane") then if not (isObjectInACLGroup("user."..acc, aclGetGroup("HABAERO"))) then cancelEvent() return outputChatBox("#000000[ #FFFF00CNH#000000 ] #FFFFFFVocê não possui #ff0000Habilitação #ffffff para conduzir este veiculo!",player,255,255,255, true) end end if (getVehicleType(source) == "Boat") then if not (isObjectInACLGroup("user."..acc, aclGetGroup("HABBOAT"))) then cancelEvent() return outputChatBox("#000000[ #FFFF00CNH#000000 ] #FFFFFFVocê não possui #ff0000Habilitação #ffffff para conduzir este veiculo!",player,255,255,255, true) end end end end addEventHandler("onVehicleStartEnter",root,JoinVehicleCar)
  11. setPedTargetingMarkerEnabled(false)
  12. toggler = { } dtype = { } syncTimer = { } currHeadLightColor = {{ }} function isVehicleBlinking( vehicle) if currHeadLightColor[vehicle] then return true else return false end end function toggleLights( veh ) if isElement( veh ) then setVehicleOverrideLights( veh, 2 ) if toggler[veh] == 1 then setVehicleLightState( veh, 0, 1 ) setVehicleLightState( veh, 1, 1 ) setVehicleLightState( veh, 2, 1 ) setVehicleLightState( veh, 3, 1 ) if veh and isElement(veh) and (getElementType(veh) == "vehicle") and getVehicleTowedByVehicle( veh ) then local veh2 = getVehicleTowedByVehicle( veh ) setVehicleLightState( veh2, 0, 1 ) setVehicleLightState( veh2, 1, 1 ) setVehicleLightState( veh2, 2, 1 ) setVehicleLightState( veh2, 3, 1 ) end toggler[veh] = 0 else if dtype[veh] == "left" then setVehicleLightState( veh, 0, 0 ) setVehicleLightState( veh, 1, 1 ) setVehicleLightState( veh, 2, 1 ) setVehicleLightState( veh, 3, 0 ) if veh and isElement(veh) and (getElementType(veh) == "vehicle") and getVehicleTowedByVehicle( veh ) then local veh2 = getVehicleTowedByVehicle( veh ) setVehicleLightState( veh2, 0, 0 ) setVehicleLightState( veh2, 1, 1 ) setVehicleLightState( veh2, 2, 1 ) setVehicleLightState( veh2, 3, 0 ) end elseif dtype[veh] == "right" then setVehicleLightState( veh, 0, 1 ) setVehicleLightState( veh, 1, 0 ) setVehicleLightState( veh, 2, 0 ) setVehicleLightState( veh, 3, 1 ) if (getElementType(veh) == "vehicle") and getVehicleTowedByVehicle( veh ) then local veh2 = getVehicleTowedByVehicle( veh ) setVehicleLightState( veh2, 0, 1 ) setVehicleLightState( veh2, 1, 0 ) setVehicleLightState( veh2, 2, 0 ) setVehicleLightState( veh2, 3, 1 ) end elseif (getElementType(veh) == "vehicle") and dtype[veh] == "all" then setVehicleLightState( veh, 0, 0 ) setVehicleLightState( veh, 1, 0 ) setVehicleLightState( veh, 2, 0 ) setVehicleLightState( veh, 3, 0 ) if veh and isElement(veh) and (getElementType(veh) == "vehicle") and getVehicleTowedByVehicle( veh ) then local veh2 = getVehicleTowedByVehicle( veh ) setVehicleLightState( veh2, 0, 0 ) setVehicleLightState( veh2, 1, 0 ) setVehicleLightState( veh2, 2, 0 ) setVehicleLightState( veh2, 3, 0 ) end end toggler[veh] = 1 end end end function lightHandler( player, cmd ) if player and isElement( player ) and getPedOccupiedVehicle( player ) then local veh = getPedOccupiedVehicle( player ) if ( not isTimer( syncTimer[veh] ) or cmd ~= dtype[veh] ) and getVehicleOccupants(veh)[0] == player then setVehicleLightState( veh, 0, 1 ) setVehicleLightState( veh, 1, 1 ) setVehicleLightState( veh, 2, 1 ) setVehicleLightState( veh, 3, 1 ) if veh and isElement(veh) and (getElementType(veh) == "vehicle") and getVehicleTowedByVehicle( veh ) then local veh2 = getVehicleTowedByVehicle( veh ) setVehicleLightState( veh2, 0, 1 ) setVehicleLightState( veh2, 1, 1 ) setVehicleLightState( veh2, 2, 1 ) setVehicleLightState( veh2, 3, 1 ) end if not currHeadLightColor[veh] then currHeadLightColor[veh] = { } currHeadLightColor[veh][1],currHeadLightColor[veh][2],currHeadLightColor[veh][3] = getVehicleHeadLightColor( veh ) end setVehicleHeadLightColor( veh, 255, 200, 0 ) if isTimer( syncTimer[veh] ) then killTimer( syncTimer[veh] ) setVehicleHeadLightColor(veh, currHeadLightColor[veh][1],currHeadLightColor[veh][2],currHeadLightColor[veh][3]) end syncTimer[veh] = setTimer( toggleLights, 380, 0, veh ) toggler[veh] = 1 dtype[veh] = cmd toggleLights( veh ) else if isTimer( syncTimer[veh] ) then killTimer( syncTimer[veh] ) local vehID = getElementData( veh, "vehicleID") if vehID then local vehID = tonumber( vehID) local colorTable = exports.GTIvehicles:getVehicleData( vehID, "light_color") or "255,255,255" local cData = split( colorTable, ",") setVehicleHeadLightColor( veh, cData[1], cData[2], cData[3]) currHeadLightColor[veh] = nil else setVehicleHeadLightColor( veh, 255, 255, 255) end end setVehicleLightState( veh, 0, 0 ) setVehicleLightState( veh, 1, 0 ) setVehicleLightState( veh, 2, 0 ) setVehicleLightState( veh, 3, 0 ) setVehicleOverrideLights( veh, 2 ) if veh and isElement(veh) and (getElementType(veh) == "vehicle") and getVehicleTowedByVehicle( veh ) then local veh2 = getVehicleTowedByVehicle( veh ) setVehicleLightState( veh2, 0, 0 ) setVehicleLightState( veh2, 1, 0 ) setVehicleLightState( veh2, 2, 0 ) setVehicleLightState( veh2, 3, 0 ) setVehicleOverrideLights( veh2, 2 ) end end end end addCommandHandler( "left", lightHandler ) addCommandHandler( "right", lightHandler ) addCommandHandler( "all", lightHandler ) addEvent("command:execute",true) addEventHandler("command:execute",resourceRoot, function(position) lightHandler(client,position) end) --//Client addEventHandler("onClientKey",getRootElement(), function(button,press) if press then if (button == "lshift" and getKeyState("a")) or (button == "a" and getKeyState("lshift")) then triggerServerEvent("command:execute",resourceRoot,"left") elseif (button == "lshift" and getKeyState("d")) or (button == "d" and getKeyState("lshift")) then triggerServerEvent("command:execute",resourceRoot,"right") elseif (button == "lshift" and getKeyState("s")) or (button == "s" and getKeyState("lshift")) then triggerServerEvent("command:execute",resourceRoot,"all") end end end)
  13. FadeCamera: local camPositions = { {-2816.0283203125, 2125.6923828125, 156.8657989502, -2720.1396484375, 1835.1181640625, 133.21673583984}, {-1145.0048828125, 879.6533203125, 9.1189212799072, -1357.7978515625, 719.6279296875, 14.321132659912}, {1135.3759765625, -1977.408203125, 78.517211914063, 1413.7529296875, -1617.5576171875, 63.588264465332}, {2160.0869140625, -102.408203125, 5.6070313453674, 1894.4580078125, -146.1396484375, 21.12876701355} } addEventHandler("onPlayerJoin",getRootElement(), function() fadeCamera(source,true,5) setCameraMatrix(source,unpack(camPositions[math.random(#camPositions)])) end) Spawn: local randomSpawnTable = { { 270.92654418945, -1986.3665771484, 797.52966308594 }, { 270.92654418945, -1986.3665771484, 797.52966308594 }, { 270.92654418945, -1986.3665771484, 797.52966308594 } } addEventHandler("onPlayerLogin",getRootElement(), function() spawnPlayer(source,unpack(randomSpawnTable[math.random(#randomSpawnTable)])) setCameraTarget(source,source) setElementModel(source, 312) giveWeapon(source,46) giveWeapon(source,9) giveWeapon(source,25,5000,true) giveWeapon(source,28,5000,true) giveWeapon(source,31,5000,true) giveWeapon(source,22,5000,true) end)
  14. --//Server addCommandHandler("sms", function(player,cmd,...) local messages = {} for i = 1,#arg do messages[i] = arg[i] end triggerClientEvent("onSMSTrigger", player, messages) end) --//Client local screenW, screenH = guiGetScreenSize() local sms = {} addEvent("onSMSTrigger", true) addEventHandler("onSMSTrigger", getRootElement(), function (newSMS) sms = newSMS end) addEventHandler("onClientRender", getRootElement(), function() local str = "" for i = 1,#sms do str = str..sms[i].."\n\n" end dxDrawText(str, (screenW * 0.2462) + 1, (screenH * 0.6833) + 1, (screenW * 0.8838) + 1, (screenH * 0.9933) + 1, tocolor(0, 0, 0, 255), 2.50, "default-bold", "left", "top", true, true, false, true, false) end) /sms <text>, or /sms <text1> <text2> <text3> Should work fine
  15. --Functions createObject moveObject createColCuboid Events: https://wiki.multitheftauto.com/wiki/OnColShapeHit https://wiki.multitheftauto.com/wiki/OnColShapeLeave Functions and events that will help you to make it
  16. local camPositions = { {-2816.0283203125, 2125.6923828125, 156.8657989502, -2720.1396484375, 1835.1181640625, 133.21673583984}, {-1145.0048828125, 879.6533203125, 9.1189212799072, -1357.7978515625, 719.6279296875, 14.321132659912}, {1135.3759765625, -1977.408203125, 78.517211914063, 1413.7529296875, -1617.5576171875, 63.588264465332}, {2160.0869140625, -102.408203125, 5.6070313453674, 1894.4580078125, -146.1396484375, 21.12876701355} } addEventHandler("onClientResourceStart",resourceRoot, function() fadeCamera(true, 5) setCameraMatrix(unpack(camPositions[math.random(#camPositions)])) end) This code must work. onClientResourceStart event will be triggered after they join and have downloaded client script. Notes: 1.onClientPlayerJoin is triggered for all players except the local player, as the local player joins the server before their client-side resources are started 2.fadeCamera and setCameraMatrix doesn't have player parameter in client side
  17. setElementInterior( player, spawns[rnd][1], spawns[rnd][2], spawns[rnd][3],spawns[rnd][4] )
  18. function Show_Groups_Window() if (getTeamName(getPlayerTeam(localPlayer)) ~= "Polisss") then if not guiGetVisible(Groups_Window) then guiSetVisible(Groups_Window, true) showCursor(true) triggerServerEvent("Request_Invite_List", localPlayer) triggerServerEvent("Send_Groups_List", localPlayer) else guiSetVisible(Groups_Window, false) guiSetVisible(Group_List_Window, false) guiSetVisible(Group_Invite_Window, false) guiSetVisible(myGroup_Invite_Window, false) guiSetVisible(MyGroup_Members_Window, false) guiSetVisible(Group_Info_Window, false) guiSetVisible(Group_Leader_Window, false) guiSetVisible(Group_Rank_Window, false) guiSetVisible(Add_Rank_Window, false) guiSetVisible(Edit_Rank_Window, false) guiSetVisible(CheckRemoveRankWindow, false) guiSetVisible(Promote_Demote_Window, false) guiSetVisible(Warn_Window, false) guiSetVisible(GroupBank_Window, false) showCursor(false) end end end bindKey("F6", "down", Show_Groups_Window)
  19. local killed_players = {} local imageTexture = dxCreateTexture("icon.png") addEventHandler("onClientPlayerSpawn",getRootElement(), function() if killed_players[source] then killed_players[source] = nil end end) addEventHandler("onClientPlayerWasted",getRootElement(), function(killer) if killer == localPlayer then killed_players[source] = true setTimer(function(source) killed_players[source] = nil end,15000,1,source) end end) addEventHandler("onClientRender",getRootElement(), function() for id,player in ipairs(getElementsByType("player")) do if killed_players[player] then local headPos = Vector3(getPedBonePosition(player,6)) dxDrawMaterialLine3D(headPos.x,headPos.y,headPos.z,headPos.x,headPos.y,headPos.z+0.7,imageTexture,1) end end end)
  20. function mcc (player,command) local team = getPlayerTeam(player) local teamName = getTeamName(team) if teamName == "SWAT" then createVehicle (432,x,y+2,z+1) outputChatBox ( "You got SWAT MCC",player,255,0,0) end end addCommandHandler ("mcc",mcc) do it in server side script
  21. https://wiki.multitheftauto.com/wiki/Scripting_Introduction
  22. local wanted_players = {} add this table at the first line of client side script
  23. --//ServerSide function traceFunction(_,_,_,_,_,player,level) if isElement(player) and level > 0 then setElementData(player,"wanted.level",true) else if getElementData(player,"wanted.level") then setElementData(player,"wanted.level",nil) end end end addDebugHook("postFunction",traceFunction,{"setPlayerWantedLevel"}) --//ClientSide local tag = dxCreateTexture("cuffs.png") addEventHandler("onClientResourceStart",resourceRoot, function() local myLevel = getPlayerWantedLevel() if myLevel > 0 then setElementData(localPlayer,"wanted.level",true) else setElementData(localPlayer,"wanted.level",nil) end for id,player in ipairs(getElementsByType("player")) do if getElementData(player,"wanted.level") then wanted_players[player] = true end end end) function dxDrawImageOnElement(TheElement,Image,distance,height,width,R,G,B,alpha) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getElementPosition(localPlayer) local distance = distance or 20 local height = height or 1 local width = width or 1 local checkBuildings = checkBuildings or true local checkVehicles = checkVehicles or false local checkPeds = checkPeds or false local checkObjects = checkObjects or true local checkDummies = checkDummies or true local seeThroughStuff = seeThroughStuff or false local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false local ignoredElement = ignoredElement or nil if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawMaterialLine3D(x, y, z+1+height-(distanceBetweenPoints/distance), x, y, z+height, Image, width-(distanceBetweenPoints/distance), tocolor(R or 255, G or 255, B or 255, alpha or 255)) end end end end addEventHandler("onClientElementDataChange",getRootElement(), function(data) if data == "wanted.level" then local value = getElementData(source,"wanted.level") wanted_players[source] = value end end) addEventHandler("onClientRender",getRootElement(), function() for id,player in ipairs(getElementsByType("player")) do if wanted_players[player] then dxDrawImageOnElement(player,tag) end end end) Also you can use this way
  24. local tag = dxCreateTexture("cuffs.png") function dxDrawImageOnElement(TheElement,Image,distance,height,width,R,G,B,alpha) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getElementPosition(localPlayer) local distance = distance or 20 local height = height or 1 local width = width or 1 local checkBuildings = checkBuildings or true local checkVehicles = checkVehicles or false local checkPeds = checkPeds or false local checkObjects = checkObjects or true local checkDummies = checkDummies or true local seeThroughStuff = seeThroughStuff or false local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false local ignoredElement = ignoredElement or nil if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawMaterialLine3D(x, y, z+1+height-(distanceBetweenPoints/distance), x, y, z+height, Image, width-(distanceBetweenPoints/distance), tocolor(R or 255, G or 255, B or 255, alpha or 255)) end end end end setTimer(function() setElementData(localPlayer,"wanted.level",getPlayerWantedLevel()) end,1000,0) addEventHandler("onClientPreRender",root,function() for id,player in ipairs(getElementsByType("player")) do if getElementData(player,"wanted.level") > 0 then dxDrawImageOnElement(player,tag) end end end)
×
×
  • Create New...