Jump to content

Lord Henry

Other Languages Moderators
  • Posts

    3,969
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by Lord Henry

  1. There's still one problem. The timer should stop when someone enters the vehicle (as driver or passenger) and restart when the vehicle goes empty (with no driver and no passenger).
  2. Done function checkVehicle (thePlayer) local v = getPedOccupiedVehicle(thePlayer); if (v) then local n = (not vehicleIsStatic(v)) and ("player") or ("map"); outputChatBox("This vehicle is from " .. n) else outputChatBox("you are't in a vehicle") end end addEventHandler("onVehicleEnter", getRootElement(), checkVehicle) function vehicleIsStatic(element) if(getElementType(element) == "vehicle") then local tag = getElementID(element); if(tag and (string.find(tag, "server_"))) then return 1; end end end function respawnExplodedVehicle () if(not vehicleIsStatic(source)) then -- Not is vehicle from map outputChatBox("The vehicle " .. getVehicleName(source) .. " was destroyed"); destroyElement(source) else setTimer(respawnVehicle, 10000, 1, source) outputChatBox("The vehicle " .. getVehicleName(source) .. " will respawn"); end end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) Test this.
  3. I tried here, but nothing happens. The message telling if the vehicle is or not from map doesn't appear. I changed the .map file but still nothing happens.
  4. Cool! Now try explode both of them but respawn only the map vehicle. The player vehicle should disappear. (destroyed)
  5. Let's use an example. I have a map with a Patriot. How will I differentiate that Patriot of the .map from a Patriot created by a player?
  6. I was thinking about creating a bool variable. If created by map map = true else map = false If map = true respawnVehicle if map = false destroyElement (vehicle)
  7. Hello everyone. I need to destroy a vehicle that is idle for 60 seconds (Freeroam already has this function, so this part is unnecessary to make.) It starts counting when the vehicle becomes totally empty, (with no driver and no passengers), if someone enters in it before 60 seconds (as passenger or driver), the counting stops and restarts when the vehicle becomes empty again.) (Freeroam already works like this.) BUT If the car is from a .map, it need to be respawned to its original position on the map. Else if the car was created by a player (F1, command, Admin Panel, scripts, etc) so it will be destroyed. How can I differentiate the vehicles created by the .map from those created by the players? Also, when the vehicle gets exploded: if it is from a .map it will respawn after 10 seconds, else if was created by a player it will be destroyed after 10 seconds. I have a little script that respawn all vehicles that have been exploded. But it respawns all the vehicles created by players too... -- 1 second = 1000 function respawnExplodedVehicle() setTimer(respawnVehicle, 10000, 1, source) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle)
  8. Yes... The resource have a client sided script and a server sided script. It calls the blips on the client sided script.
  9. ERROR: editor_test\portaoilhaFAs.lua:12: attempt to call global 'getPedOccupiedVehice' (a nil value) Solved! gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 ) ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão. function GateIlha1Open (hitElement) if hitElement and getElementType ( hitElement ) == 'player' then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitElement)), aclGetGroup("MapEditor")) then outputChatBox ( "Acesso permitido.", hitElement, 0, 255, 0, true ) moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 ) local veh = getPedOccupiedVehicle(hitElement) if veh then setElementFrozen(veh, true) end setElementFrozen( hitElement, true ) toggleAllControls( hitElement, false ) setTimer ( function( player ) local veh = getPedOccupiedVehicle(player) if veh then setElementFrozen(veh, false) end setElementFrozen( player, false ) toggleAllControls( player, true ) end, 3000, 1, hitElement ) outputChatBox ( "Aguarde o portão se abrir.", hitElement, 0, 255, 0, true ) else outputChatBox ( "Acesso negado.", hitElement, 255, 0, 0, true ) end end end addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open ) function GateIlha1Close () moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 ) end addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close ) 8. local veh = getPedOccupiedVehice(hitElement) and 15. local veh = getPedOccupiedVehice(player) I changed to "Vehicle". Thanks by the help! It's working well now
  10. WARNING: editor_test\portaoilhaFAs.lua:8: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] ERROR: editor_test\portaoilhaFAs.lua:8: attempt to concatenate a boolean value
  11. It just let me with no control of the vehicle during the time, but not Freeze the vehicle. The vehicle must stop immediately when it collides. But this time, none error happened.
  12. WARNING: editor_test\portaoilhaFAs.lua:8: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] ERROR: editor_test\portaoilhaFAs.lua:8: attempt to concatenate a boolean value
  13. This worked by foot, but not with vehicle. The vehicle needs to be freezed too.
  14. ERROR: editor_test\portaoilhaFAs.lua:8: attempt to call global 'getLocalPlayer' (a nil value)
  15. I know it, but I tried it on clientside and nothing happened...
  16. Well...I need to freeze a player during 3 seconds when he collides a ColCuboid, independent if he is in a vehicle or not. After this time, the player is unfreezed and will be only freeze again if he goes out the collider and enters it again. The collider is on a serverside script, but I read at the "Wiki MTA" an information that Freeze commands are only clientside... I tried to make all the script clientside but when I did, the script simply doesn't work and don't show any error. Reason: The player must wait the gate's movement ending so he can pass. The gate's movement lasts 3 seconds. PS: The gate is already working fine with the collider. Here is the serverside script working well without the freeze commands: gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 ) ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão. function GateIlha1Open (source) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("MapEditor")) then moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 ) outputChatBox ( "Acesso permitido.", source, 0, 255, 0, true ) else outputChatBox ( "Acesso negado.", source, 255, 0, 0, true ) end end addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open ) function GateIlha1Close () moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 ) end addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close ) And here is the script with the freeze command and timer: gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 ) ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão. function GateIlha1Open (source, player) local player = getLocalPlayer() if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("MapEditor")) then outputChatBox ( "Acesso permitido.", source, 0, 255, 0, true ) moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 ) setElementFrozen( player, true ) toggleAllControls( player, false ) setTimer ( function( source ) setElementFrozen( player, false ) toggleAllControls( player, true ) end, 3000, 1 ) outputChatBox ( "Aguarde o portão se abrir.", source, 0, 255, 0, true ) else outputChatBox ( "Acesso negado.", source, 255, 0, 0, true ) end end addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open ) function GateIlha1Close () moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 ) end addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close ) How to create a Freeze with collider and timer?
  17. Oh... Thanks by the information, even if I could change that blip, it will show only to me, but I need to show to all players. I will search a tutorial about creating my own radar.
  18. Hello everyone. I programmed a script that create VIP houses and when it does, it creates a green house blip on the map where the house was created. When this house is bought out by someone, the blip is changed to red house blip. But I want to keep an Yellow House blip instead of the green house blip. The blips only appear on the map when I hold the key " i " (example of how it should appear) The script calls the blips with this: bindKey( 'i', 'both', function( key, keyState ) if keyState == 'down' then for k, v in ipairs ( getElementsByType( 'marker', getResourceRootElement() ) ) do if getElementData( v, 'HSV_INFO' ) and getElementData( v, 'HSV_INFO' )[7] then if getElementData( v, 'HSV_INFO' )[7] ~= '' then createBlipAttachedTo( v, 32 ); --Red house blip else createBlipAttachedTo( v, 31 ); --Green house blip --createBlipAttachedTo( v, 64 ); --Yellow house blip end; end; end; else for k, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do if getElementData( v, 'HSV_INFO' ) then for k, elem in ipairs( getAttachedElements( v ) ) do if getElementType( elem ) == 'blip' then destroyElement( elem ); end; end; end; end; end; end ); I tried to create a new blip and call him, but the MTA doesn't recognize it and send a white square instead of my new blip. Any idea?
  19. I think it solved the problem, but now appears another problem: ERROR: [admin]\sistema-home\coreh_server.lua:56: attempt to call field 'Query' (a nil value) coreh_server.lua: local sqly = { Query = executesqlQuery }; addEventHandler( 'onResourceStart', resourceRoot, function() sqly.Query( "CREATE TABLE IF NOT EXISTS house_data (\ ID INTEGER, en_X REAL, en_Y REAL, en_Z REAL,\ en_tX REAL, en_tY REAL, en_tZ REAL,\ ex_X REAL, ex_Y REAL, ex_Z REAL,\ ex_tX REAL, ex_tY REAL, ex_tZ REAL,\ int INTEGER, dim INTEGER, cost INTEGER, owner TEXT, key TEXT )" ); for i, v in ipairs( getElementsByType( 'player' ) ) do setElementData( v, 'k_len', tonumber( get( 'keyLength' ) ) ); local acc = getPlayerAccount( v ); if not isGuestAccount( acc ) then setElementData( v, 'HSV_accountName', getAccountName( acc ) ); end; setElementData( v, 'mrk_in', nil ); end; local hr = sqly.Query( "SELECT * FROM house_data" ); for i = 1, #hr do createHouseVip( false, hr[i].ID, hr[i].owner, hr[i].key, hr[i].en_X, hr[i].en_Y, hr[i].en_Z, hr[i].en_tX, hr[i].en_tY, hr[i].en_tZ, hr[i].ex_X, hr[i].ex_Y, hr[i].ex_Z, hr[i].ex_tX, hr[i].ex_tY, hr[i].ex_tZ, hr[i].int, hr[i].dim, hr[i].cost ); end; end ); addEventHandler( 'onResourceStop', resourceRoot, function() for i, v in ipairs( getElementsByType( 'player' ) ) do setElementData( v, 'k_len', nil ); setElementData( v, 'HSV_accountName', nil ); end; end ); addEventHandler( 'onPlayerJoin', root, function() setElementData( source, 'k_len', tonumber( get( 'keyLength' ) ) ); end ); addEventHandler( 'onPlayerLogin', root, function( _, acc ) setElementData( source, 'HSV_accountName', getAccountName( acc ) ); end ); addEventHandler( 'onPlayerLoout', root, function( _, acc ) setElementData( source, 'HSV_accountName', nil ); end ); addCommandHandler( 'home', function( player ) if isObjectInACLGroup( 'user.'..getAccountName( getPlayerAccount( player ) ), aclGetGroup( 'Console' ) ) or hasObjectPermissionTo( player, 'function.banPlayer', false ) then if not getElementData( player, 'HPV_Opened' ) and not getElementData( player, 'mrk_in' ) then triggerClientEvent( player, 'HPV_SetVisible', root, true ); end; else outputChatBox( 'Acesso negado para este comando!', player, 255, 36, 51 ); end; end ); addEvent( 'onPlayerAttemptCreateHouseVip', true ); addEventHandler( 'onPlayerAttemptCreateHouseVip', root, function( rt ) createHouseVip( true, #sqly.Query( "SELECT * FROM house_data" ) + 1, '', '', unpack( rt ) ); outputChatBox( 'A casa VIP foi criada com sucesso!', client, 255, 255, 0 ); end );
×
×
  • Create New...