Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. These are tables, later used to store the marker elements using player as table index.
  2. markers = { } blips = { } function inVEH ( player ) if ( getElementModel ( source ) == 420 ) then local x, y, z = unpack ( dropoffs [ math.random ( #dropoffs ) ] ) markers [ player ] = createMarker ( x, y, z, "cylinder", 1.5, 255, 0, 0 ) blips [ player ] = createBlipAttachedTo ( markers [ player ], 41 ) else if ( isElement ( markers [ player ] ) ) then destroyElement ( markers [ player ] ) end if ( isElement ( blips [ player ] ) ) then destroyElement ( blips [ player ] ) end end end addEventHandler ( "onVehicleEnter", getRootElement(), inVEH ) function outVEH ( player ) if ( getElementModel ( source ) == 420 ) then if ( isElement ( markers [ player ] ) ) then destroyElement ( markers [ player ] ) end if ( isElement ( blips [ player ] ) ) then destroyElement ( blips [ player ] ) end end end addEventHandler ( "onVehicleExit", getRootElement(), outVEH )
  3. local dropoffs = { [1]={1802.951171875, -1889.1865234375, 13.185905456543}, [2]={1784.349609375, -1890.255859375, 13.176010131836} } function rMarker() local x, y, z = unpack ( dropoffs [ math.random ( #dropoffs ) ] ) createMarker ( x, y, z, "cylinder", 1.5, 255, 0, 0 ) end addCommandHandler("heyy", rMarker)
  4. Both wrong, you are trying to unpack a number. createMarker ( unpack ( dropoffs [ math.random ( #dropoffs ) ] ), "cylinder", 1.5, 255, 0, 0 )
  5. Replace that 10 with #dropOffs.
  6. I'm using it to log some data and it works perfectly.
  7. Castillo

    [HELP] chat

    I'll give you the one I edited for my server: -- client: local textsToDraw = {} local hideown local showtime local characteraddition local maxbubbles local showthebubbles = true function income(player,message) if player ~= getLocalPlayer() or not hideown then addText(player,message,messagetype) end end function addText(player,message,messagetype) local notfirst = false for i,v in ipairs(textsToDraw) do if v[1] == player then v[4] = v[4] + 1 notfirst = true end end local infotable = {player,message,messagetype,0} table.insert(textsToDraw,infotable) if not notfirst then setTimer(removeText,showtime + (#message * characteraddition),1,infotable) end end function removeText(infotable) for i,v in ipairs(textsToDraw) do if v[1] == infotable[1] and v[2] == infotable[2] then for i2,v2 in ipairs(textsToDraw) do if v2[1] == v[1] and v[4] - v2[4] == 1 then setTimer(removeText,showtime + (#v2[2] * characteraddition),1,v2) end end table.remove(textsToDraw,i) break end end end function getTextsToRemove() for i,v in ipairs(textsToDraw) do if v[1] == source then removeText(v) end end end function handleDisplay() if showthebubbles then for i,v in ipairs(textsToDraw) do if isElement(v[1]) then if getElementHealth(v[1]) > 0 then local camPosXl, camPosYl, camPosZl = getPedBonePosition (v[1], 6) local camPosXr, camPosYr, camPosZr = getPedBonePosition (v[1], 7) local x,y,z = (camPosXl + camPosXr) / 2, (camPosYl + camPosYr) / 2, (camPosZl + camPosZr) / 2 --local posx,posy = getScreenFromWorldPosition(x,y,z+0.25) local cx,cy,cz = getCameraMatrix() local px,py,pz = getElementPosition(v[1]) local distance = getDistanceBetweenPoints3D(cx,cy,cz,px,py,pz) local posx,posy = getScreenFromWorldPosition(x,y,z+0.020*distance+0.10) local elementtoignore1 = getPedOccupiedVehicle(getLocalPlayer()) or getLocalPlayer() local elementtoignore2 = getPedOccupiedVehicle(v[1]) or v[1] if posx and distance <= 45 and ( isLineOfSightClear(cx,cy,cz,px,py,pz,true,true,false,true,false,true,true,elementtoignore1) or isLineOfSightClear(cx,cy,cz,px,py,pz,true,true,false,true,false,true,true,elementtoignore2) ) and ( not maxbubbles or v[4] < maxbubbles ) then -- change this when multiple ignored elements can be specified local width = dxGetTextWidth(v[2],1,"default") dxDrawRectangle(posx - (3 + (0.5 * width)),posy - (2 + (v[4] * 20)),width + 5,19,tocolor(0,0,0,255)) dxDrawRectangle(posx - (6 + (0.5 * width)),posy - (2 + (v[4] * 20)),width + 11,19,tocolor(0,0,0,40)) dxDrawRectangle(posx - (8 + (0.5 * width)),posy - (1 + (v[4] * 20)),width + 15,17,tocolor(0,0,0,255)) dxDrawRectangle(posx - (10 + (0.5 * width)),posy - (1 + (v[4] * 20)),width + 19,17,tocolor(0,0,0,40)) dxDrawRectangle(posx - (10 + (0.5 * width)),posy - (v[4] * 20) + 1,width + 19,13,tocolor(0,0,0,255)) dxDrawRectangle(posx - (12 + (0.5 * width)),posy - (v[4] * 20) + 1,width + 23,13,tocolor(0,0,0,40)) dxDrawRectangle(posx - (12 + (0.5 * width)),posy - (v[4] * 20) + 4,width + 23,7,tocolor(0,0,0,255)) local r,g,b = 255,255,255 dxDrawText(v[2],posx - (0.5 * width),posy - (v[4] * 20),posx - (0.5 * width),posy - (v[4] * 20),tocolor(r,g,b,255),1,"default","left","top",false,false,false) end end end end end end function getServerSettings() triggerServerEvent("onAskForBubbleSettings",getLocalPlayer()) end function saveSettings(settings) showtime = settings[1] characteraddition = settings[2] maxbubbles = settings[3] hideown = settings[4] addEvent("onChatbubblesMessageIncome",true) addEventHandler("onChatbubblesMessageIncome",getRootElement(),income) end function toggleBubblesOnOff() showthebubbles = not showthebubbles outputChatBox("Toggled chatbubbles " ..( not showthebubbles and "#FF0000off#FFFFFF." or "#00FF00on#FFFFFF." ),255,255,255,true) end addEventHandler("onClientPlayerQuit",getRootElement(),getTextsToRemove) addEventHandler("onClientRender",getRootElement(),handleDisplay) addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getServerSettings) addEvent("onBubbleSettingsReturn",true) addEventHandler("onBubbleSettingsReturn",getRootElement(),saveSettings) addCommandHandler("chatbubbles",toggleBubblesOnOff) -- server: local showtime = tonumber(get("DefaultTime")) local characteraddition = tonumber(get("PerCharacterAddition")) local maxbubbles = get("MaxBubbles") if maxbubbles == "false" then maxbubbles = false else maxbubbles = tonumber(maxbubbles) end local hideown = get("HideOwn") if hideown == "true" then hideown = true else hideown = false end function sendMessageToClient(player,message) triggerClientEvent(source,"onChatbubblesMessageIncome",source,player,message) end addEvent ( "onLocalChatMessage", true ) addEventHandler("onLocalChatMessage",getRootElement(),sendMessageToClient) function returnSettings() local settings = { showtime, characteraddition, maxbubbles, hideown } triggerClientEvent(source,"onBubbleSettingsReturn",getRootElement(),settings) end addEvent("onAskForBubbleSettings",true) addEventHandler("onAskForBubbleSettings",getRootElement(),returnSettings) In your local chat script put this after the outputChatBox line: triggerEvent ( "onLocalChatMessage", v, player, msg )
  8. math.random returns a random number from another number, e.g: result = math.random ( 10 ) outputChatBox ( result ) that'll get a random number of 10. With #table you can get the total amount of items inside a table ( NOTE: IT MUST BE AN INDEXED TABLE ).
  9. You don't need a loop to get a random value. Use: math.random to get a random index of the table.
  10. Create a table, place many coordinates there, get a random index and unpack the coordinates, then create the marker.
  11. Castillo

    irc problem

    You did it while the server was running and without refreshing ACL?
  12. Castillo

    irc problem

    Add the resource to the ACL group "Admin" at acl.xml.
  13. Change: addEventHandler ( "onClientMarkerHit", root, warpit ) To: addEventHandler ( "onClientMarkerHit", pickPed, warpit )
  14. Tenes que scriptear cada funcion por tu cuenta, ya el slothbot es un script muy grande y aun asi, no es perfecto.
  15. Well, it wasn't my intention to insult you.
  16. That function is used to set a sound ELEMENT effect state, I think that you can't disable weapon sounds.
  17. Try with this: http://pastebin.com/Ggf6Rckg
  18. Yes, the same functions are used for skins/weapons/vehicles.
  19. Which part was a joke? P.S: This is off topic.
  20. "exports" is used to use an exported function from another resource.
  21. There isn't an script like that if I'm right, but you can make it.
  22. -- client side: pickPed = createMarker(1790.33105, -1909.81689, 13.03162, "cylinder", 1.5, 255, 0, 0) function warpit ( hitElement ) if ( hitElement == localPlayer ) then triggerServerEvent ( "doIt", localPlayer ) end end addEventHandler ( "onClientMarkerHit", root, warpit ) -- server side: createMarker(1777.95203, -1892.48059, 12.38782, "cylinder", 0.9, 255, 0, 0) taxiPed = createPed(252, 1789.95386, -1910.94507, 13.03228) taxiVeh = createVehicle(420, 1777.95203, -1892.48059, 12.38782) function pickPed ( ) local vehicle = getPedOccupiedVehicle ( source ) if ( vehicle ) then warpPedIntoVehicle ( taxiPed, vehicle, 2 ) end end addEvent ( "doIt", true ) addEventHandler ( "doIt", root, pickPed )
×
×
  • Create New...