Jump to content

Hero192

Members
  • Posts

    512
  • Joined

  • Last visited

Everything posted by Hero192

  1. But i want it destroy after the fire in 1 second any idea? should i add the setTimer in client / server side
  2. So should i use only server side? what i have to do in client
  3. I tried that but nothing happened anyone can help me for that ? --Client side: addEventHandler("onWeaponFire", root, function( ) for _, p in ipairs ( getElementsByType ( "player" ) ) do local tear = getPedWeapon(p) if (tear == 17) then triggerServerEvent ("takeweapon",getLocalPlayer()) end end end ) --Server side: addEvent( "takeweapon", true ) addEventHandler("takeweapon", g_Root, function() setTimer ( takeWeapon( tear),1000,1) end )
  4. ok thanks i will try it can you or someone answer my question at this topic please? https://forum.multitheftauto.com/viewtopic.php?f=91&t=90181
  5. Hello there,i want to release an script but to start on it i need to know this what im gonna tell you I want when the player fire the weapon ID == 17 the element be destroyed I tried that but failed,please give me the functions / events what should i use,thanks in advance I tried that but nothing happened anyone can help me for that ? --Client side: addEventHandler("onWeaponFire", root, function( ) for _, p in ipairs ( getElementsByType ( "player" ) ) do local tear = getPedWeapon(p) if (tear == 17) then triggerServerEvent ("takeweapon",getLocalPlayer()) end end end ) --Server side: addEvent( "takeweapon", true ) addEventHandler("takeweapon", g_Root, function() setTimer ( takeWeapon( tear),1000,1) end )
  6. Hello,i'am gonna release the resource of Drug delivery to the community and after testing it i found one bug, What's it? If two players or more spawned the truck to deliver it to the marker, only one person who gonna take money and when the first person hit the marker the elements(marker/blip/vehicle) be destroyed only for who hited the marker and the guy who didn't hit it he keep with the vehicle only but other elements being invislbe and showing only for one person exept "Vehicle" Here's the code have a look on it maybe you'll fix it easly than me,thanks local ped = createPed(29, 1602.55, -1489.33, 13.59,180) function onDrugDeliveryPedClick(button, state, absX, absY, wx, wy, wz, element) if element and getElementType(element) == "ped" and state=="down" and button=="left" then local x, y, z = getElementPosition(element) --if getTeamName(getPlayerTeam(element)) ~= "Criminal" then outputChatBox("Drug Delivery: You must be criminal.",255,0,0) return end if getElementData(element,"Name") then if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz)<=3 then guiSetVisible(Window,true) end end end end addEventHandler("onClientClick", rootElement, onDrugDeliveryPedClick) addEventHandler("onClientPedDamage",root, function () if getElementData(source,"Name") then cancelEvent() end end) function Location1() markerlocation1 = createMarker (2661.95, -1429.37, 29.49, "cylinder", 4, 238, 44, 44, 255) blipLS = createBlipAttachedTo (markerlocation1, 51) addEventHandler( "onClientMarkerHit", markerlocation1, function ( hitPlayer, d ) if isElement(markerlocation1) then destroyElement(markerlocation1) destroyElement(blipLS) end triggerServerEvent("doPayClient", hitPlayer) end ) end function Location2() markerlocation2 = createMarker (-2642.98, 1371.07, 7.16, "cylinder", 4,238, 44, 44, 255) blipSF = createBlipAttachedTo (markerlocation2, 51) addEventHandler( "onClientMarkerHit", markerlocation2, function ( hitPlayer, d ) if isElement(markerlocation2) then destroyElement(markerlocation2) destroyElement(blipSF) end triggerServerEvent("doPayClient2", hitPlayer) end ) end function Location3() markerlocation3 = createMarker (1064.73, 2342.83, 9.82, "cylinder", 4, 238, 44, 44, 255) blipLV = createBlipAttachedTo (markerlocation3, 51) addEventHandler( "onClientMarkerHit", markerlocation3, function ( hitPlayer, d ) if isElement(markerlocation3) then destroyElement(markerlocation3) destroyElement(blipLV) end triggerServerEvent("doPayClient3", hitPlayer) end ) end function onRejectClick() if (source == reject) then setCameraTarget(localPlayer) guiSetVisible(Window, false) showCursor(false) end end addEventHandler("onClientGUIClick", guiRoot, onRejectClick) function missionButton() if (source == accept) then setCameraTarget (localPlayer) if (guiRadioButtonGetSelected(location1)) then triggerServerEvent ("givePVehicle",getLocalPlayer()) Location1() guiSetVisible (Window,false) showCursor (false) elseif (guiRadioButtonGetSelected(location2)) then --assuming that locaion2 contains the location 2 radio button option triggerServerEvent ("givePVehicle",getLocalPlayer()) Location2() guiSetVisible (Window,false) showCursor (false) end end end addEventHandler("onClientGUIClick", guiRoot, missionButton) function missionButton2() if (source == accept) then if (guiRadioButtonGetSelected(location3)) then --assuming that locaion3 contains the location 3 radio button option triggerServerEvent ("givePVehicle",getLocalPlayer()) Location3() guiSetVisible (Window,false) showCursor (false) end end end addEventHandler("onClientGUIClick", guiRoot, missionButton2) --Server side: local vehicles = {} addEvent("doPayClient", true) addEventHandler( "doPayClient", root, function() givePlayerMoney(source, 2000) setPlayerWantedLevel(source, getPlayerWantedLevel(source)+1) if isElement(vehicles[source]) then destroyElement(vehicles[source]) end end ) addEvent("doPayClient2", true) addEventHandler( "doPayClient2", root, function() givePlayerMoney(source, 4000) setPlayerWantedLevel(source, getPlayerWantedLevel(source)+2) if isElement(vehicles[source]) then destroyElement(vehicles[source]) end end ) addEvent("doPayClient3", true) addEventHandler( "doPayClient3", root, function() givePlayerMoney(source, 6000) setPlayerWantedLevel(source, getPlayerWantedLevel(source)+3) if isElement(vehicles[source]) then destroyElement(vehicles[source]) end end ) addEvent("givePVehicle", true) addEventHandler( "givePVehicle", root, function() local vehicle = createVehicle (482,1605.42, -1472.97, 13.58,0,0,0) vehicles[source] = vehicle warpPedIntoVehicle(source,vehicles[source]) end )
  7. By the way,How may i use the Peds table in this F11 texts , i mean i want the texts set in the Peds table pos and shows in the F11 texts local pedPos = { {2321.06, 36.8, 26.48,88}, {-553.84, 2594, 53.93,258}, {-1969.19, -2427.74, 30.63,233} } local skins = {73,179} local peds = {} addEventHandler("onClientResourceStart", resourceRoot, function() for i=1, # peds do peds[i] = createPed(skins[math.random(1, #skins)], traderpPos[i][1], traderpPos[i][2], traderpPos[i][3]) if peds[i] then setElementFrozen(traders[i], true) if pedPos[i][4] then setPedRotation( pedsi], pedPos[i][4]) end end end end )
  8. The same message still repeating
  9. I tried but i failed thats why im here ;p it was now its fullcode addEvent ( "onClientUserSettingChange", true ) addEventHandler ( "onClientUserSettingChange", root, function ( g, v ) if ( g == "usersettings_usetopbar" ) then if not tobool ( v ) and useTopbar then useTopbar = false removeEventHandler ( "onClientRender", root, dxDrawNotificationBar ) elseif tobool ( v ) and not useTopbar then useTopbar = true addEventHandler ( "onClientRender", root, dxDrawNotificationBar ) end elseif ( g == "usersetting_notification_joinquitmessages" ) then joinquit = v elseif ( g == "usersetting_notification_nickchangemessages" ) then namechanges = v end end ) local maxMessages = 5; local DefaultTime = 8; local moveSpeed = 2; local sx, sy = guiGetScreenSize ( ) local DefaultPos = true; local messages_top = { } local toDo = { } local messageDelay = 500 local TheResourceName = getResourceName ( getThisResource ( ) ) local lastAutoMessage = 1 local t = 0 function sendClientMessage ( msg, r, g, b, img, checkImgPath ) if ( checkImgPath == nil ) then checkImgPath = true; end if ( img and sourceResource and checkImgPath ) then img = ":"..tostring(getResourceName(sourceResource)).."/"..img; end return _sendClientMessage ( msg, r, g, b, img ); end function _sendClientMessage ( msg, r, g, b, img ) if ( useTopbar ) then if ( not exports.NGLogin:isClientLoggedin ( ) ) then return end local msg, r, g, b = tostring ( msg ), tonumber ( r ) or 255, tonumber ( g ) or 255, tonumber ( b ) or 255 local img = img or ""; if ( img ~= "" and not fileExists ( img ) ) then img = "" end local data = { msg, r, g, b, getTickCount ( ) + DefaultTime*1000, -25, true, img } if ( getTickCount ( ) - t >= messageDelay ) then table.insert ( messages_top, data ) t = getTickCount ( ) else table.insert ( toDo, data ) end else outputChatBox ( msg, r, g, b ) end end addEvent ( TheResourceName..":sendClientMessage", true ) addEventHandler ( TheResourceName..":sendClientMessage", root, _sendClientMessage ) local width = (sx/1.95) local t2 = getTickCount ( ) function dxDrawNotificationBar ( ) if ( #toDo > 0 and getTickCount ( ) -t >= messageDelay ) then local d = toDo[1] d[5] = getTickCount ( ) + DefaultTime*1000 table.insert ( messages_top, d ) table.remove ( toDo, 1 ) t = getTickCount ( ) end local doRemove = { } for i, v in pairs ( messages_top ) do local i = i - 1 local msg, r, g, b, rTime, y = unpack ( v ) local continue = true if ( rTime < getTickCount ( ) and v[7] ) then messages_top[i+1][7] = false end if ( v[7] ) then if ( messages_top[i] ) then toY = messages_top[i][6] + 25 else toY = 0 end if ( y ~= toY ) then if ( y < toY ) then y = y + moveSpeed if ( y > toY ) then y = toY end else y = y - moveSpeed if ( y < toY ) then y = toY end end else if ( #messages_top > maxMessages ) then messages_top[1][5] = 0 messages_top[1][7] = false end end else y = y - moveSpeed if ( y < -25 ) then continue = false end end messages_top[i+1][6] = y local lColor = tocolor ( 0, 0, 0, 255 ) dxDrawRectangle ( (sx/2-width/2), rsy*y, width, rsy*25, tocolor ( 0, 0, 0, 120 ) ) dxDrawLine ( (sx/2-width/2), rsy*y, (sx/2-width/2)+width, rsy*y, lColor ) dxDrawLine ( (sx/2-width/2), rsy*y, (sx/2-width/2), rsy*(y+25), lColor ) dxDrawLine ( (sx/2+width/2), rsy*y, (sx/2+width/2), rsy*(y+25), lColor ) dxDrawLine ( (sx/2+width/2)-width, rsy*(y+25), (sx/2+width/2), rsy*(y+25), lColor ) if ( v[8] and v[8] ~= "" ) then dxDrawImage ( (sx/2-width/2)+3, (rsy*y)+2, rsx*21, rsy*21, v[8] ); dxDrawImage ( (sx/2-width/2)+(width-25), (rsy*y)+2, rsx*21, rsy*21, v[8] ); end dxDrawText ( v[1], 0, rsy*y, sx, rsy*(y+25), tocolor ( v[2], v[3], v[4], 255 ), rsx*1, "default-bold", "center", "center", true, false, false, true ) if ( not continue ) then table.insert ( doRemove, i+1 ) end end if ( #doRemove > 0 ) then for i, v in ipairs ( doRemove ) do if ( messages_top [ v ] ) then table.remove ( messages_top, v ) end end end end addEventHandler ( "onClientRender", root, dxDrawNotificationBar ) function tobool ( input ) local input = tostring ( input ):lower ( ) if ( input == "true" ) then return true elseif ( input == "false" ) then return false else return nil end end
  10. Hello again, i have problem with the top bar chat It make spams,i want the messages doesn't repeat like if the message = "You already got the job" It doesn't repeat all the time the player hit the job,it must keep showing but only with one line not using all lines with the same message ,i hope you understand me 2nd problem i want the last rectangle show with black color 0,0,0 and other with ALPHA ,i wish someone give me an support hand on it please i tried before but i failed thats why im asking local width = (sx/1.95) local t2 = getTickCount ( ) function dxDrawNotificationBar ( ) if ( #toDo > 0 and getTickCount ( ) -t >= messageDelay ) then local d = toDo[1] d[5] = getTickCount ( ) + DefaultTime*1000 table.insert ( messages_top, d ) table.remove ( toDo, 1 ) t = getTickCount ( ) end local doRemove = { } for i, v in pairs ( messages_top ) do local i = i - 1 local msg, r, g, b, rTime, y = unpack ( v ) local continue = true if ( rTime < getTickCount ( ) and v[7] ) then messages_top[i+1][7] = false end if ( v[7] ) then if ( messages_top[i] ) then toY = messages_top[i][6] + 25 else toY = 0 end if ( y ~= toY ) then if ( y < toY ) then y = y + moveSpeed if ( y > toY ) then y = toY end else y = y - moveSpeed if ( y < toY ) then y = toY end end else if ( #messages_top > maxMessages ) then messages_top[1][5] = 0 messages_top[1][7] = false end end else y = y - moveSpeed if ( y < -25 ) then continue = false end end messages_top[i+1][6] = y local lColor = tocolor ( 0, 0, 0, 255 ) dxDrawRectangle ( (sx/2-width/2), rsy*y, width, rsy*25, tocolor ( 0, 0, 0, 120 ) ) dxDrawLine ( (sx/2-width/2), rsy*y, (sx/2-width/2)+width, rsy*y, lColor ) dxDrawLine ( (sx/2-width/2), rsy*y, (sx/2-width/2), rsy*(y+25), lColor ) dxDrawLine ( (sx/2+width/2), rsy*y, (sx/2+width/2), rsy*(y+25), lColor ) dxDrawLine ( (sx/2+width/2)-width, rsy*(y+25), (sx/2+width/2), rsy*(y+25), lColor ) if ( v[8] and v[8] ~= "" ) then dxDrawImage ( (sx/2-width/2)+3, (rsy*y)+2, rsx*21, rsy*21, v[8] ); dxDrawImage ( (sx/2-width/2)+(width-25), (rsy*y)+2, rsx*21, rsy*21, v[8] ); end dxDrawText ( v[1], 0, rsy*y, sx, rsy*(y+25), tocolor ( v[2], v[3], v[4], 255 ), rsx*1, "default-bold", "center", "center", true, false, false, true ) if ( not continue ) then table.insert ( doRemove, i+1 ) end end if ( #doRemove > 0 ) then for i, v in ipairs ( doRemove ) do if ( messages_top [ v ] ) then table.remove ( messages_top, v ) end end end end addEventHandler ( "onClientRender", root, dxDrawNotificationBar )
  11. I mean in the F11 M not in the radar (mini map)
  12. I mean,i want show the rectangle in the map too what you gave me it show the texts without rectangles.
  13. Thank you alot one more thing there's a way for adding the rectangle in the text who attacked between blips 23,42? because i tried and i failed
  14. But it shows to all blips and the text ="none" , color = "255,255,255" Even when i set my own text / Color it doesn't works setElementData(23, "name", "whatever you want") setElementData(23, "color", "0,255,0")
  15. The color Doesn't working it show as black even if i set it to another one
  16. I stuck in showing the text on the map Please do an example custom text with custom color and let the text be attacked to blip "23"and "42". Already tried in line 25 / 26 but i have no idea about how to make like 2 Text/Color for this code in table Please guys help me if you know how local textFont = "sans" local textScale = 0.8 local heightPadding = 1 local widthPadding = 1 local xOffset = 5 local minAlpha = 10 local textAlpha = 255 local rectangleColor = tocolor(0,0,0,155) local floor = math.floor local w,h = guiGetScreenSize() local function drawMapStuff() if isPlayerMapVisible() then local sx,sy,ex,ey = getPlayerMapBoundingBox() local mw,mh = ex-sx,sy-ey local cx,cy = (sx+ex)/2,(sy+ey)/2 local ppuX,ppuY = mw/6000,mh/6000 local fontHeight = dxGetFontHeight(textScale,textFont) local yOffset = fontHeight/2 local blips = getElementsByType("blip") for k,v in ipairs(blips) do if tonumber(getBlipIcon(v)) == 23 then if tonumber(getBlipIcon(v)) == 42 then local px,py = getElementPosition(v) local x = floor(cx+px*ppuX+xOffset) local y = floor(cy+py*ppuY-yOffset) local jname = getElementData(v,"name") local nameLength = dxGetTextWidth(jname,textScale,textFont) local r,g,b = unpack(getElementData(v,"color")) local _,_,_,a = getBlipColor(v) if a>minAlpha then dxDrawRectangle(x-widthPadding,y+heightPadding,nameLength+widthPadding*2,fontHeight-heightPadding*1,rectangleColor,false) dxDrawText(jname,x,y,x+nameLength,y+fontHeight,tocolor(r,g,b,textAlpha),textScale,textFont,"left","top",false,false,false,true) end end end end end end addEventHandler("onClientRender",getRootElement(),drawMapStuff)
  17. I stuck in showing the text on the map Please do an example custom text with custom color and let the text be attacked to blip "23"and "42". Already tried in line 25 / 26 but i have no idea about how to make like 2 Text/Color for this code in table Please guys help me if you know how local textFont = "sans" local textScale = 0.8 local heightPadding = 1 local widthPadding = 1 local xOffset = 5 local minAlpha = 10 local textAlpha = 255 local rectangleColor = tocolor(0,0,0,155) local floor = math.floor local w,h = guiGetScreenSize() local function drawMapStuff() if isPlayerMapVisible() then local sx,sy,ex,ey = getPlayerMapBoundingBox() local mw,mh = ex-sx,sy-ey local cx,cy = (sx+ex)/2,(sy+ey)/2 local ppuX,ppuY = mw/6000,mh/6000 local fontHeight = dxGetFontHeight(textScale,textFont) local yOffset = fontHeight/2 local blips = getElementsByType("blip") for k,v in ipairs(blips) do if tonumber(getBlipIcon(v)) == 23 then if tonumber(getBlipIcon(v)) == 42 then local px,py = getElementPosition(v) local x = floor(cx+px*ppuX+xOffset) local y = floor(cy+py*ppuY-yOffset) local jname = getElementData(v,"name") local nameLength = dxGetTextWidth(jname,textScale,textFont) local r,g,b = unpack(getElementData(v,"color")) local _,_,_,a = getBlipColor(v) if a>minAlpha then dxDrawRectangle(x-widthPadding,y+heightPadding,nameLength+widthPadding*2,fontHeight-heightPadding*1,rectangleColor,false) dxDrawText(jname,x,y,x+nameLength,y+fontHeight,tocolor(r,g,b,textAlpha),textScale,textFont,"left","top",false,false,false,true) end end end end end end addEventHandler("onClientRender",getRootElement(),drawMapStuff)
  18. Thanks you ,and i got your point via pm,sorry
  19. EDIT: and how can i do Table for Blips blip = createBlip( 1303.72, 1502.84, 10.82,23,2,0, 170, 15, 255) blipLS = createBlip(1304.8, 1254.75, 10.82, 23,2, 0, 170, 15, 255) setBlipVisibleDistance (blipLS,500) setBlipVisibleDistance (blip,500)
  20. Thanks for help ,can you explain to me why you did ?
  21. Hello everybody im doing a simple shop i want the PEDs be in Two places LV / LS but i failed in attacking the PEDs table to client side Here's the part of my code: Client side: addEventHandler ( 'onClientClick', root, function ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if ( clickedElement ) and ( getElementType ( clickedElement ) == 'ped' ) then if ( clickedElement == peds[shop] ) then if ( guiGetVisible ( window ) == false ) then guiSetVisible ( window,true ) end end end end ) --Server side: local pedPos = { {1304.8, 1254.75, 10.82}; {1844.0552978516, -2640.2033691406, 13}; } local skins = {287} local peds = {} addEventHandler("onResourceStart",resourceRoot, function () for i,v in pairs(pedPos) do local shop = #peds + 1 peds[shop] = createPed(skins[math.random(#skins)],v[1],v[2],v[3]) if peds[shop] then setElementData(peds[shop],"shop",true) setElementFrozen(peds[shop],true) if v[4] then setPedRotation(peds[shop],v[4]) end end end end)
×
×
  • Create New...