Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. Castillo

    Diferencias

    addEvent ( "onChangeVehicle", true ) addEventHandler ( "onChangeVehicle", getRootElement(), function ( ) outputChatBox ( "Hola Mundo!" ) end ) triggerEvent ( "onChangeVehicle", localPlayer )
  2. @X-SHADOW: Could you please stop posting bull****? my script works perfect.
  3. Seriously, you must have something wrong in your server, it works perfectly fine.
  4. http://www.mediafire.com/?s7ysplbztr02pjp
  5. Topic moved to correct section.
  6. How could it ever work if you forgot to add this: addEvent ( "stopCarRadio", true ) addEventHandler ( "stopCarRadio", root, function ( car ) if ( isElement ( carSounds[ car ] ) ) then destroyElement ( carSounds[ car ] ) end end )
  7. Castillo

    Diferencias

    addEvent se usa para crear eventos propios, en la wiki lo dice.
  8. Please upload your resource to: http://mediafire.com/
  9. Try copying my last code again.
  10. Are you sure you've copied my last code?
  11. I've tested what sniper posted and it only removed parts of the world map.
  12. Random codes won't help him.
  13. @X-SHADOW: Stop posting the same thing, that'll just stop the sound, it'll stay there still. @sckatchof: I've tested it with two vehicles, both times is destroyed.
  14. I've fixed you the main problem, now is all up to you.
  15. The sound is destroyed, it works fine here.
  16. -- client side: sounds = "http://www.181.fm/winamp.pls?station=181-power&style=mp3" carSounds = { } function playRadioCar ( car ) local x,y,z = getElementPosition ( car ) if ( isElement ( carSounds[ car ] ) ) then destroyElement ( carSounds[ car ] ) end carSounds[ car ] = playSound3D ( sounds, x, y, z, true ) attachElements ( carSounds[ car ], car ) end addEvent ( "playRadioCar", true ) addEventHandler( "playRadioCar", getRootElement(), playRadioCar ) addEvent ( "stopCarRadio", true ) addEventHandler ( "stopCarRadio", root, function ( car ) if ( isElement ( carSounds[ car ] ) ) then destroyElement ( carSounds[ car ] ) end end ) -- server side: local carRadios = { } -- Create a table. function attachradio ( thePlayer ) local car = getPedOccupiedVehicle ( thePlayer ) if ( car ) then if ( isElement ( carRadios[ car ] ) ) then -- If the vehicle already has a radio... outputChatBox ( "This vehicle already has a radio.", thePlayer, 255, 0, 0 ) else local x, y, z = getElementRotation ( car ) carRadios[ car ] = createObject ( 2232, 1016.2437133789, -2473.1711425781, 7.6930656433105, x, y, z ) -- Create radio object for the vehicle. attachElements ( carRadios[ car ], car, 0, -4, 0.45 ) -- Attach the radio to the vehicle. triggerClientEvent ( "playRadioCar", root, car ) outputChatBox ( "Here is the radio!", thePlayer ) end end end addCommandHandler ( "radio", attachradio ) addCommandHandler ( "stopradio", function ( thePlayer ) local car = getPedOccupiedVehicle ( thePlayer ) if ( car ) then if ( not isElement ( carRadios[ car ] ) ) then -- If the vehicle has no radio... outputChatBox ( "This vehicle has no radio.", thePlayer, 255, 0, 0 ) else triggerClientEvent ( "stopCarRadio", root, car ) destroyElement ( carRadios[ car ] ) end end end )
  17. local carRadios = { } -- Create a table. function attachradio ( thePlayer ) local car = getPedOccupiedVehicle ( thePlayer ) if ( car ) then if ( isElement ( carRadios[ car ] ) ) then -- If the vehicle already has a radio... outputChatBox ( "This vehicle already has a radio.", thePlayer, 255, 0, 0 ) else local x, y, z = getElementRotation ( car ) carRadios[ car ] = createObject ( 2232, 1016.2437133789, -2473.1711425781, 7.6930656433105, x, y, z ) -- Create radio object for the vehicle. attachElements ( carRadios[ car ], car, 0, -4, 0.45 ) -- Attach the radio to the vehicle. triggerClientEvent ( "playRadioCar", root, car ) outputChatBox ( "Here is the radio!", thePlayer ) end end end addCommandHandler ( "radio", attachradio ) This will check if the vehicle already has a radio, if so, output a message to the player.
  18. -- adminclickcars_cl: function playermenu ( ) if ( not isElement ( mainwindow ) ) then victimemt = getElementData ( getRootElement(), "adminclickselplayer" ) mainwindow = guiCreateWindow ( 750, 250, 240, 180, "Car menu", false ) -- fixveh = guiCreateButton ( 0.05, 0.15, 0.4, 0.15, "Fix vehicle", true, mainwindow ) blowveh = guiCreateButton ( 0.55, 0.15, 0.4, 0.15, "Blow up vehicle", true, mainwindow ) -- delveh = guiCreateButton ( 0.05, 0.35, 0.4, 0.15, "Delete vehicle", true, mainwindow ) colveh = guiCreateButton ( 0.55, 0.35, 0.4, 0.15, "Colour vehicle", true, mainwindow ) -- upgveh = guiCreateButton ( 0.05, 0.55, 0.4, 0.15, "Upgrade vehicle", true, mainwindow ) selowner = guiCreateButton ( 0.55, 0.55, 0.4, 0.15, "Select driver", true, mainwindow ) -- closebutton = guiCreateButton ( 0.30, 0.8, 0.4, 0.15, "Close", true, mainwindow ) addEventHandler( "onClientGUIClick", delveh, vc, false ) addEventHandler( "onClientGUIClick", closebutton, disable, false ) addEventHandler( "onClientGUIClick", selowner, selectowner, false ) end end addEvent ("carmenu", true) addEventHandler ("carmenu", getRootElement(), playermenu) function disable () guiSetVisible ( mainwindow, false ) setElementData ( localPlayer, "adminclickselplayer", nil ) setElementData ( getRootElement(), "adminclickopen", false ) end function selectowner () thecar = getElementData ( localPlayer, "adminclickselplayer" ) occupant = getVehicleOccupant ( thecar ) guiSetVisible ( mainwindow, false ) if ( occupant ) then setElementData ( localPlayer, "adminclickselplayer", occupant ) else outputChatBox ( "This vehicle does not have a driver", 255, 0, 0 ) end end function vc ( ) local thecar = getElementData ( localPlayer, "adminclickselplayer" ) if ( thecar and isElement ( thecar ) ) then triggerServerEvent ( "destroyVehicle", localPlayer, thecar ) end end -- adminclick.lua: setElementData (getRootElement(), "adminclickopen", false) setElementData (getRootElement(), "adminclickmousebind", false) function clickmenu (mouseButton, buttonState, clickedElement, worldPosX, worldPosY, worldPosZ, screenPosX, screenPosY) if ( buttonState == "down" ) then if ( hasObjectPermissionTo ( source, "function.kickPlayer", true ) ) then if ( not getElementData ( source, "adminclickopen" ) ) then if ( getElementData ( source, "adminclickmousebind") ) then if ( mouseButton == "right" ) then if ( clickedElement ) then if ( getElementType (clickedElement) == "player" ) then name = getPlayerName (clickedElement) setElementData ( source, "adminclickselplayer", tostring(name) ) setElementData ( source, "adminclickopen", true) triggerClientEvent (source,"playermenu", getRootElement() ) elseif ( getElementType (clickedElement) == "vehicle" ) then thecar = clickedElement setElementData ( source, "adminclickselplayer", thecar ) triggerClientEvent (source,"carmenu", getRootElement() ) end end elseif ( mouseButton == "left" ) then --outputChatBox ( worldPosX .. "," .. worldPosY .. "," .. worldPosZ ) --[[ Random send cars & players flying, can be abused col = createColCircle ( worldPosX, worldPosY, 15) colelements = getElementsWithinColShape (col) for theKey,theElement in ipairs(colelements) do if ( getElementType (theElement) == "player" ) then setElementVelocity ( theElement, 2, 0, 5) elseif ( getElementType (theElement) == "vehicle" ) then setElementVelocity ( theElement, 2, 0, 1.5) end end --]] end end end end end end addEventHandler( "onPlayerClick", getRootElement(), clickmenu ) function onstart() players = getElementsByType ( "player" ) -- get a table of all the players in the server for theKey,player in ipairs(players) do if ( hasObjectPermissionTo ( player, "function.kickPlayer", true ) ) then setElementData ( player, "adminclickopen", false) setElementData ( player, "adminclickmousebind", false) bindKey (player, "o", "down", showmouse, player ) end end end addEventHandler ( "onResourceStart", getRootElement(), onstart ) function showmouse ( player ) showCursor ( player, not isCursorShowing ( player ) ) setElementData ( player, "adminclickmousebind", isCursorShowing ( player ) ) end function bindmouse () if ( hasObjectPermissionTo ( source, "function.kickPlayer", true ) ) then setElementData ( source, "adminclickopen", false ) setElementData ( source, "adminclickmousebind", false ) bindKey ( source, "o", "down", showmouse ) end end addEventHandler ("onPlayerLogin", getRootElement(), bindmouse ) function killplayer () victimemt = getElementData ( source, "adminclickselplayer" ) victim = getPlayerFromName (tostring(victimemt)) if ( isElement(victim) ) then killPed (victim) outputChatBox ("You just killed " .. victimemt, source, 125, 125, 125 ) outputChatBox ("You just admin killed!", victim, 125, 125, 125 ) else outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) end end addEvent("killplayer", true) addEventHandler ("killplayer", getRootElement(), killplayer) function muteplayer () victimemt = getElementData ( source, "adminclickselplayer" ) victim = getPlayerFromName (tostring(victimemt)) if ( isElement(victim) ) then if ( getElementData ( victim, "muted" ) == false ) then setPlayerMuted ( victim, true ) setElementData (victim, "muted", true) outputChatBox ("You just muted " .. victimemt, source, 125, 125, 125 ) outputChatBox ("You just got muted.", victim, 125, 125, 125 ) elseif ( getElementData ( victim, "muted" ) == true ) then setPlayerMuted ( victim, false ) setElementData (victim, "muted", false) outputChatBox ("You just unmuted " .. victimemt, source, 125, 125, 125 ) outputChatBox ("You just got unmuted.", victim, 125, 125, 125 ) end else outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) end end addEvent("mute", true) addEventHandler ("mute", getRootElement(), muteplayer) function freezeplayer () victimemt = getElementData ( source, "adminclickselplayer" ) victim = getPlayerFromName (tostring(victimemt)) if ( isElement(victim) ) then if ( getElementData ( victim, "froozen" ) == false ) then toggleAllControls ( victim, false, true, false ) setElementData (victim, "froozen", true) outputChatBox ("You just freezed " .. victimemt, source, 125, 125, 125 ) outputChatBox ("You just got freezed.", victim, 125, 125, 125 ) elseif ( getElementData ( victim, "froozen" ) == true ) then toggleAllControls ( victim,true,true,true ) setElementData (victim, "froozen", false) outputChatBox ("You're now free to move " .. victimemt, source, 125, 125, 125 ) outputChatBox ("You just got un-froozen.", victim, 125, 125, 125 ) end else outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) end end addEvent("freeze", true) addEventHandler ("freeze", getRootElement(), freezeplayer) function banplayer (reason) victimemt = getElementData ( source, "adminclickselplayer" ) victim = getPlayerFromName (tostring(victimemt)) if ( isElement(victim) ) then banPlayer ( victim, true, true, true, getRootElement(), tostring(reason), 20) outputChatBox ("You just banned " .. victimemt, source, 125, 125, 125 ) outputChatBox ( getPlayerName(source) .. " has just banned " .. victimemt .. " for: " .. tostring(reason), source, 255, 0, 0 ) else outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) end end addEvent("ban", true) addEventHandler ("ban", getRootElement(), banplayer) function kickplayer (reason) victimemt = getElementData ( source, "adminclickselplayer" ) victim = getPlayerFromName (tostring(victimemt)) if ( isElement(victim) ) then kickPlayer ( victim, getRootElement(), reason) outputChatBox ("You just kicked " .. victimemt, source, 125, 125, 125 ) outputChatBox ( getPlayerName(source) .. " has just kicked " .. victimemt .. " for: " .. tostring(reason), source, 255, 0, 0 ) else outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) end end addEvent("kick", true) addEventHandler ("kick", getRootElement(), kickplayer) addEvent ( "destroyVehicle", true ) addEventHandler ( "destroyVehicle", root, function ( theVehicle ) if ( theVehicle ) then destroyElement ( theVehicle ) setElementData ( source, "adminclickselplayer", nil ) end end ) That works, even when the script is a real mess.
  19. -- client side: sounds = "http://www.181.fm/winamp.pls?station=181-power&style=mp3" function playRadioCar ( car ) local x,y,z = getElementPosition ( car ) sound = playSound3D ( sounds, x, y, z, true ) attachElements ( sound, car ) end addEvent ( "playRadioCar", true ) addEventHandler( "playRadioCar", getRootElement(), playRadioCar ) -- server side: local carRadios = { } -- Create a table. function attachradio ( thePlayer ) local car = getPedOccupiedVehicle ( thePlayer ) if ( car ) then if ( isElement ( carRadios[ car ] ) ) then -- If the vehicle already has a radio... destroyElement ( carRadios[ car ] ) -- Destroy it. end local x, y, z = getElementRotation ( car ) carRadios[ car ] = createObject ( 2232, 1016.2437133789, -2473.1711425781, 7.6930656433105, x, y, z ) -- Create radio object for the vehicle. attachElements ( carRadios[ car ], car, 0, -4, 0.45 ) -- Attach the radio to the vehicle. triggerClientEvent ( "playRadioCar", root, car ) outputChatBox ( "Here is the radio!", thePlayer ) end end addCommandHandler ( "radio", attachradio )
  20. Then, you want to destroy the clicked vehicle, not all server vehicles.
  21. The script creates the radio object, I've tested and it worked.
  22. Indeed TAPL, his script is just a mess, I don't really understand what he's trying to do.
×
×
  • Create New...