Jump to content

Sande

Members
  • Posts

    186
  • Joined

  • Last visited

Everything posted by Sande

  1. Now the problem is, it doens´t get if i have like level 1 vip its still says you dont have it.
  2. Can you help me with this: function givePermission (thePlayer, command, target ) local playeraccount = getPlayerAccount ( target ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local viplevel = 1 setAccountData(playeraccount, "viplevel", viplevel ) outputChatBox("[VIP-Management] VIP annettu pelaajalle "..getPlayerName(target).." onnistuneesti.", thePlayer, 0,255,0) else outputChatBox("[VIP-Management] Error.", thePlayer, 255,0,0) end end addCommandHandler("viplevel-1", givePermission ) I cant set someplayer account data idk why. it goes to else message.
  3. Im trying to make a bindKey in serverside what opening the gui in clientside. But the key is not going to binded at it says bad argument. Serverside: function openGUI(thePlayer) if getAccountData (thePlayer, "viplevel", 1 ) == true then triggerClientEvent(thePlayer, "openVpanel1", thePlayer ) else outputChatBox("[VIP] You dont have permission to open vip-panel (1)", thePlayer, 255,0,0) end end function bind() bindKey( "F7", "down", openGUI ) end addEventHandler("onResourceStart", getRootElement(), bind ) Clientside function openPanel ( ) local state = guiGetVisible ( vipGUI [ "window" ] ) guiSetVisible ( vipGUI [ "window" ], not state ) showCursor ( not state ) end addEvent( "openVpanel1", true ) addEventHandler( "openVpanel1", getLocalPlayer(), openPanel )
  4. I getted it work, and how: Il do the player check in server side, and then triggerclient event the sound. but thanks.
  5. Hey, im trying to make a command what puts text and voice to players who have elementData "metroLippu" true. But now the problem is, the count of element datas like example 4, and if i do the command il get 4 x sounds, and 4x text to the chat. Only me, other players who have that element data true doesn´t hear anything or get the message to the chat. Only they who use the command. Can someone help me, it needs to work like, i can write the command and then all players who have that elementData true hear that sound, and get message to chat. That is so inportant to me please help, or fix the whole code. Thanks :9 BTW: code is clientside, and sounds added to meta.xml. function kuulutus1() local players = getElementsByType ( "player" ) -- get a table of all the players in the server for theKey,thePlayer in ipairs(players) do if getElementData ( thePlayer, "metroLippu") == true then outputChatBox("[Metro] Hyvät matkustajat, jatkamme matkaa hetken kuluttua.", thePlayer, 0,255,0) local kuulutus = playSound("kuulutus/m1.mp3") setSoundVolume(kuulutus, 2.0) end end end addCommandHandler("metro-k1", kuulutus1 )
  6. I am trying to make ticket system for trains. But when i am in Ticket check team and do /hsl-tarkasta myname , it doens´t say anything. idk whats wrong. No erros. help me pls. TrainDriverTeam = createTeam ( "Train-driver", 0, 17, 255 ) WorkersTeam = createTeam ("Ticket-inspector", 0, 153, 255 ) function ostaLippu11 ( thePlayer ) if getPlayerMoney(thePlayer) < 5000 then outputChatBox("[HSL] Sinulla ei ole tarpeeksi rahaa ostaaksesi metrolippua.", thePlayer, 255, 0, 0) return end outputChatBox("[HSL] Ostit metrolipun.", thePlayer, 0,255,0) takePlayerMoney(thePlayer, 5000) local id = math.random(1,20) if (id) then outputChatBox ("[HSL] Sinun lippu-numero on : "..tostring(id)..".", thePlayer, 0,255,0) outputChatBox("[HSL] Pelaaja "..getPlayerName(thePlayer).." osti lipun.", getPlayerFromName("Sisuviina"), 0,255,0) outputChatBox ("[HSL] Pelaajan "..getPlayerName(thePlayer).." Lippunumero on: "..tostring(id)..".", getPlayerFromName("Sisuviina"), 0,255,0) givePlayerMoney (getPlayerFromName("Sisuviina"), 5000) setElementData(thePlayer, "metroLippu", true) end end addCommandHandler("hsl-lippu", ostaLippu11 ) function tarkastaLippu(thePlayer, command, target) local team = getPlayerTeam(thePlayer) if getTeamName (team) == "Ticket-inspector" then local target = getPlayerFromName ( target ) if ( target ) then if getElementData(target, "metroLippu" ) == true then outputChatBox("[HSL] Pelaajalla "..getPlayerFromName(target).." on voimassa oleva matkustusoikeus.", thePlayer, 0,255,0) else outputChatBox("[HSL] Pelaajalla "..getPlayerFromName(target).." ei ole voimassa olevaa matkustusoikeutta.", thePlayer, 255,0,0) end end end end addCommandHandler("hsl-tarkasta", tarkastaLippu )
  7. Thank you very much! it works now
  8. Idk, but it still going to "VIRHE" mean "ERROR". function deaOik(thePlayer, command) local target = getPlayerFromName ( target ) if ( target ) then setElementData(target, "DEAaccespass1", true) outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) else outputChatBox("VIRHE", thePlayer, 255,0,0) end end addCommandHandler("dea-oikeus1k-on", deaOik ) function deaOik1(thePlayer, command) local target = getPlayerFromName ( target ) if ( target ) then setElementData(target, "DEAaccespass1", false) outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) else outputChatBox("VIRHE", thePlayer, 255,0,0) end end addCommandHandler("dea-oikeus1k-of", deaOik1 )
  9. No debug errors, it just not get the player, and puts error. i mean my own error message "VIRHE". function deaOik(thePlayer, target, command) local target = getPlayerFromName ( "target" ) if ( target ) then setElementData(target, "DEAaccespass1", true) outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) else outputChatBox("VIRHE", thePlayer, 255,0,0) end end addCommandHandler("dea-oikeus1k-on", deaOik ) function deaOik1(thePlayer, target, command) local target = getPlayerFromName ( "target" ) if ( target ) then setElementData(target, "DEAaccespass1", false) outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) else outputChatBox("VIRHE", thePlayer, 255,0,0) end end addCommandHandler("dea-oikeus1k-of", deaOik1 )
  10. Hey, i am try to make a script what set to the target player element data true, but idk. If i do like /dea-oikeus1k-on Sisuviina goes just error, it just not found my name. Someone can help? i forget all about getTarget, or theres some weird error. function deaOik(thePlayer, target, command) local target = getPlayerFromName ( target ) if ( target ) then setElementData(getPlayerFromName("target"), "DEAaccespass1", true) outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) else outputChatBox("VIRHE", thePlayer, 255,0,0) end end addCommandHandler("dea-oikeus1k-on", deaOik ) function deaOik1(thePlayer, target, command) local target = getPlayerFromName ( target ) if ( target ) then setElementData(getPlayerFromName("target"), "DEAaccespass1", false) outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) else outputChatBox("VIRHE", thePlayer, 255,0,0) end end addCommandHandler("dea-oikeus1k-of", deaOik1 )
  11. its not worked, but thanks i getted it worked by your code when i edited it thanks.
  12. Hey, im in big trouble i dont have much skills to get all players etc. the idea is if player elementdata is false and he are in dimension 10999 or 10998 then the script put him to dimension 0. please help. function tarkasta(dimension) local rValue = { }; for i, v in ipairs ( getElementsByType ( "player" ) ) do if ( getElementDimension ( v ) == dimension ) then if ( getElementDimension ( player ) == 10999 or 10998 ) then if getElementData (player, "inMission") == false then setElementDimension(player, 0) end end end end function ajastimet() outputChatBox("SANDEN TIMERI KÄYNNISSÄ!->EVENT 403", root, 0,255,0) setTimer(tarkasta, 100,0) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), ajastimet )
  13. They not spawning, all time 0 zombies when i move.
  14. Zombies not spawning, im in right dimension.
  15. ZombieLimit = get("zombies.MaxZombies")-- HOW MANY ZOMBIES SHOULD EXIST AT MAXIMUM? ZombieStreaming = get("zombies.StreamMethod") -- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints ZombiePedSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,188,195,206,209,212,229,230,258,264,277,280,287 } --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY) --ZombiePedSkins = {7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,36,37,38,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,75,76,77,78,79,80,81,82,83,85,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,150,151,152,153,154,155,156,157,158,159,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,209,210,211,212,213,214,215,216,217,218,219,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,275,276,277,278,279,280,281,282,283,284,285,286,287,288 } ZombieSpeed = get("zombies.Speed") if ZombieSpeed == 0 then --super slow zombies (goofy looking) chaseanim = "WALK_drunk" checkspeed = 2000 elseif ZombieSpeed == 1 then -- normal speed chaseanim = "run_old" checkspeed = 1000 elseif ZombieSpeed == 2 then -- rocket zombies (possibly stressful on server) chaseanim = "Run_Wuzi" checkspeed = 680 else -- defaults back to normal chaseanim = "run_old" checkspeed = 1000 end resourceRoot = getResourceRootElement() moancount =0 moanlimit = 10 everyZombie = { } --IDLE BEHAVIOUR OF A ZOMBIE function Zomb_Idle (ped) if isElement(ped) then if ( getElementData ( ped, "status" ) == "idle" ) and ( isPedDead ( ped ) == false ) and (getElementData (ped, "zombie") == true) then local action = math.random( 1, 6 ) if action < 4 then -- walk a random direction local rdmangle = math.random( 1, 359 ) setPedRotation( ped, rdmangle ) setPedAnimation ( ped, "PED", "Player_Sneak", -1, true, true, true) setTimer ( Zomb_Idle, 7000, 1, ped ) elseif action == 4 then -- get on the ground setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, true) setTimer ( Zomb_Idle, 4000, 1, ped ) elseif action == 5 then -- stand still doing nothing setPedAnimation ( ped ) setTimer ( Zomb_Idle, 4000, 1, ped ) end end end end --BEHAVIOUR WHILE CHASING PLAYERS function Zomb_chase (ped, Zx, Zy, Zz ) if isElement(ped) then if (getElementData ( ped, "status" ) == "chasing") and (getElementData (ped, "zombie") == true) then local x, y, z = getElementPosition( ped ) if (getElementData ( ped, "target" ) == nil) and getElementData ( ped, "Tx" ) ~= false then local Px = getElementData ( ped, "Tx" ) local Py = getElementData ( ped, "Ty" ) local Pz = getElementData ( ped, "Tz" ) local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, x, y, z )) if (Pdistance < 1.5 ) then setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped ) end end local distance = (getDistanceBetweenPoints3D( x, y, z, Zx, Zy, Zz )) if (distance < 1 ) then -- IF THE PED HASNT MOVED if (getElementData ( ped, "target" ) == nil) then local giveup = math.random( 1, 15 ) if giveup == 1 then setElementData ( ped, "status", "idle" ) else local action = math.random( 1, 2 ) if action == 1 then setPedAnimation ( ped ) triggerClientEvent ( "Zomb_Punch", getRootElement(), ped ) setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped ) setTimer ( Zomb_chase, 2000, 1, ped, x, y, z ) elseif action == 2 then setPedAnimation ( ped ) triggerClientEvent ( "Zomb_Jump", getRootElement(), ped ) setTimer ( Zomb_chase, 3500, 1, ped, x, y, z ) end end else local Ptarget = (getElementData ( ped, "target" )) if isElement(Ptarget) then local Px, Py, Pz = getElementPosition( Ptarget ) local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )) if (Pdistance < 1.2 ) then -- ATTACK A PLAYER IF THEY ARE CLOSE if ( isPedDead ( Ptarget ) ) then --EAT A DEAD PLAYER setPedAnimation ( ped ) setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, false) setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 10000, 1, ped ) setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 10000, 1, ped ) zmoan(ped) else local action = math.random( 1, 6 ) if action == 1 then setPedAnimation ( ped) triggerClientEvent ( "Zomb_Jump", getRootElement(), ped ) setTimer ( Zomb_chase, 2000, 1, ped, x, y, z ) else setPedAnimation ( ped) triggerClientEvent ( "Zomb_Punch", getRootElement(), ped ) setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped ) setTimer ( Zomb_chase, 2000, 1, ped, x, y, z ) end end else if ( isPedDead (Ptarget) ) then setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped ) setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 1800, 1, ped ) else local action = math.random( 1, 2 ) if action == 1 then setPedAnimation ( ped) triggerClientEvent ( "Zomb_Punch", getRootElement(), ped ) setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped ) setTimer ( Zomb_chase, 2000, 1, ped, x, y, z ) elseif action == 2 then setPedAnimation ( ped) triggerClientEvent ( "Zomb_Jump", getRootElement(), ped ) setTimer ( Zomb_chase, 2000, 1, ped, x, y, z ) end end end else setElementData ( ped, "status", "idle" ) end end else setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true) --KEEP WALKING setTimer ( Zomb_chase, checkspeed, 1, ped, x, y, z ) --CHECK AGAIN end end end end --SET THE DIRECTION OF THE ZOMBIE function setangle () for theKey,ped in ipairs(everyZombie) do if isElement(ped) then if ( getElementData ( ped, "status" ) == "chasing" ) then local x local y local z local px local py local pz if ( getElementData ( ped, "target" ) ~= nil ) then local ptarget = getElementData ( ped, "target" ) if isElement(ptarget) then x, y, z = getElementPosition( ptarget ) px, py, pz = getElementPosition( ped ) else setElementData ( ped, "status", "idle" ) x, y, z = getElementPosition( ped ) px, py, pz = getElementPosition( ped ) end zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU setPedRotation( ped, zombangle ) elseif ( getElementData ( ped, "target" ) == nil ) and (getElementData ( ped, "Tx" ) ~= false) then --IF THE PED IS AFTER THE PLAYERS LAST KNOWN WHEREABOUTS x = getElementData ( ped, "Tx" ) y = getElementData ( ped, "Ty" ) z = getElementData ( ped, "Tz" ) px, py, pz = getElementPosition( ped ) zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU setPedRotation( ped, zombangle ) end end end end end --SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANGES addEventHandler ( "onElementDataChange", getRootElement(), function ( dataName ) if getElementType ( source ) == "ped" and dataName == "status" then if (getElementData (source, "zombie") == true) then if ( isPedDead ( source ) == false ) then if (getElementData ( source, "status" ) == "chasing" ) then local Zx, Zy, Zz = getElementPosition( source ) setTimer ( Zomb_chase, 1000, 1, source, Zx, Zy, Zz ) local newtarget = (getElementData ( source, "target" )) if isElement (newtarget) then if getElementType ( newtarget ) == "player" then setElementSyncer ( source, newtarget ) end end zmoan(source) elseif (getElementData ( source, "status" ) == "idle" ) then setTimer ( Zomb_Idle, 1000, 1, source) elseif (getElementData ( source, "status" ) == "throatslashing" ) then local tx,ty,tz = getElementPosition( source ) local ptarget = getElementData ( source, "target" ) if isElement(ptarget) then local vx,vy,vz = getElementPosition( ptarget ) local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz)) if (zombdistance < .-- s8) --> then zmoan(source) setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true) setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true) setTimer ( Playerthroatbitten, 2300, 1, ptarget, source) setTimer ( function (source) if ( isElement ( source ) ) then setElementData ( source, "status", "idle" ) end end, 5000, 1, source ) else setElementData ( source, "status", "idle" ) end else setElementData ( source, "status", "idle" ) end end elseif (getElementData ( source, "status" ) == "dead" ) then setTimer ( Zomb_delete, 10000, 1, source) end end end end) --RESOURCE START/INITIAL SETUP function outbreak(startedResource) newZombieLimit = get("" .. getResourceName(startedResource) .. ".Zlimit") if newZombieLimit ~= false then if newZombieLimit > ZombieLimit then newZombieLimit = ZombieLimit end else newZombieLimit = ZombieLimit end WoodTimer = setTimer ( WoodSetup, 2000, 1) -- CHECKS FOR BARRIERS if startedResource == getThisResource() then -- call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") --ADDS TO SCOREBOARD local allplayers = getElementsByType ( "player" ) for pKey,thep in ipairs(allplayers) do setElementData ( thep, "dangercount", 0 ) end local alivePlayers = getAlivePlayers () for playerKey, playerValue in ipairs(alivePlayers) do setElementData ( playerValue, "alreadyspawned", true ) end if ZombieSpeed == 2 then MainTimer1 = setTimer ( setangle, 200, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION (fast) else MainTimer1 = setTimer ( setangle, 400, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION end MainTimer3 = setTimer ( clearFarZombies, 3000, 0) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYERS if ZombieStreaming == 1 then MainTimer2 = setTimer ( SpawnZombie, 2500, 0 ) --Spawns zombies in random locations elseif ZombieStreaming == 2 then MainTimer2 = setTimer ( SpawnpointZombie, 2500, 0 ) --spawns zombies in zombie spawnpoints end end end addEventHandler("onResourceStart", getRootElement(), outbreak) function player_Connect()
  16. I dont found the places, il changed in some spawn function setElementDimension but now any zombies not spawning. idk what wrong.
  17. I found only one place, in custom exported function wheres createPed including dimension.
  18. Hey, i am trying to spawn zombies to other dimension than 0 in mtasa. I dont found the function where i can edit the dimension to 10999 can someone give a line number where i can edit it. pls.
  19. Hey, i am trying to make this command only for if player is level 7. I am using castillos exp_system, help thanks function spawnLambo(thePlayer, theLevel, commandName) local account = getPlayerAccount ( thePlayer ) local myLevel = exports.exp_system:getPlayerLevel ( thePlayer ) if exports ["exp_system"]:getPlayerLevel ( thePlayer ) < 7 then --[[Problem place, need to check if level 7 then can spawn--]] local x, y, z = getElementPosition ( thePlayer ) local lamborgini = createVehicle ( 477, x, y, z + 10 ) warpPedIntoVehicle ( thePlayer, lamborgini ) outputChatBox("[server] Spawnaus onnistui.", thePlayer, 0,255,0) else outputChatBox("[server] Et ole riittävän iso levelinen spawnataksesi tätä kohdetta.", thePlayer, 255,0,0) end end addCommandHandler("lauto", spawnLambo )
  20. Sande

    Fuel help!!

    Hey, i try to edit this fuel script. Can someone do a function like, if fuel is 0%. Its turn engine off alltime. local carFuel = {}; local gasStations = {}; local gasStationsBlip = {}; local gasStationsMarkers = {}; addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() local xml = xmlLoadFile("carData.xml"); local xmlNodes = xmlNodeGetChildren(xml); for i,node in ipairs(xmlNodes) do carFuel[tonumber(xmlNodeGetAttribute(node,'id'))] = tonumber(xmlNodeGetAttribute(node,'fuel')); end xmlUnloadFile(xml); local xml = xmlLoadFile("garageData.xml"); local xmlNodes = xmlNodeGetChildren(xml); for i,node in ipairs(xmlNodes) do local name = xmlNodeGetAttribute(node,'name'); local x = tonumber(xmlNodeGetAttribute(node,'x')); local y = tonumber(xmlNodeGetAttribute(node,'y')); local z = tonumber(xmlNodeGetAttribute(node,'z')); gasStationsBlip[name] = createBlip(x,y,z,51,0,0,0,0,0,0,450); local moreKids = xmlNodeGetChildren(node); gasStationsMarkers[name] = {}; for i,v in ipairs(moreKids) do local mx = tonumber(xmlNodeGetAttribute(v,'x')); local my = tonumber(xmlNodeGetAttribute(v,'y')); local mz = tonumber(xmlNodeGetAttribute(v,'z')); gasStationsMarkers[name][i] = createMarker(mx,my,mz,'corona',3,128,128,0,128); setElementData(gasStationsMarkers[name][i],'gasStation',true); end end xmlUnloadFile(xml); end ) function fuelUse(p) local vehicle = getPedOccupiedVehicle(p); if vehicle then local team = getPlayerTeam (source) if getTeamName (team) == "Freeroam" then return end setTimer(fuelUse,1000,1,p); if getVehicleType(vehicle) ~= 'Automobile' and getVehicleType(vehicle) ~= 'Bike' and getVehicleType(vehicle) ~= 'Monster Truck' and getVehicleType(vehicle) ~= 'Quad' then return end if getVehicleController(vehicle) ~= p then return end --### if getVehicleEngineState(vehicle) == false then return end --### local fuel = getCarFuel(vehicle) if fuel == 0 then setVehicleEngineState(vehicle,false); return end --### --[[local speedX, speedY, speedZ = getElementVelocity(vehicle); vel = (speedX^2 + speedY^2 + speedZ^2)^(0.5)+(math.random(100,1000)/25000);]] local newX,newY,newZ = getElementPosition(vehicle); local oldX = getElementData(vehicle,'oldX') or newX; local oldY = getElementData(vehicle,'oldY') or newY; local oldZ = getElementData(vehicle,'oldZ') or newZ; local vel = (getDistanceBetweenPoints2D(oldX,oldY,newX,newY)/70)+(math.random(100,1000)/50000); local oldX = setElementData(vehicle,'oldX',newX); local oldY = setElementData(vehicle,'oldY',newY); local oldZ = setElementData(vehicle,'oldZ',newZ) --if vel < 0.01 then return end --### local remainingFuel = takeCarFuel(vehicle,vel); if remainingFuel < 0.001 then remainingFuel = 0; outputChatBox('Your car has ran out of fuel.',getVehicleController(v), 255, 0, 0); setVehicleEngineState(vehicle,false); end end end function startFuelUse(p,seat,jacked) local team = getPlayerTeam (p) if getTeamName (team) == "Freeroam" then return end if getVehicleType(source) ~= 'Automobile' and getVehicleType(source) ~= 'Bike' and getVehicleType(source) ~= 'Monster Truck' and getVehicleType(source) ~= 'Quad' then return end if seat ~= 0 then return end if getCarFuel(source) <= 0 then setVehicleEngineState(source,false); end setTimer(fuelUse,1000,1,p); ajastin() end addEventHandler("onVehicleEnter",getRootElement(),startFuelUse) function ajastin() setTimer(tarkasta,500,0) end function tarkasta() if getCarFuel(source) <= 0 then setVehicleEngineState(source,false); end end function switchEngine(playerSource) local theVehicle = getPedOccupiedVehicle(playerSource); if theVehicle and getVehicleController(theVehicle) == playerSource then local state = getVehicleEngineState(theVehicle) if state then setVehicleEngineState(theVehicle, false); outputChatBox('Car engine turned off.',playerSource); else if getCarFuel(theVehicle) <= 0 then return end setVehicleEngineState(theVehicle, true); outputChatBox('Car engine turned on.',playerSource); end end end addCommandHandler("engine",switchEngine); addEvent('pedSyphonVehicle',true); function pedSyphon(v) if getCarFuel(source) >= carFuel[-1] then outputChatBox("You are holding as much fuel as you can carry.",getVehicleController(v), 255, 0, 0); return end local n = math.random(100,200)/1000; local left = takeCarFuel(v,n); local total = addCarFuel(source,n); if left <= 0 then outputChatBox("That car has no more fuel left.",getVehicleController(v), 255, 0, 0); return end triggerClientEvent("onPedSyphonFuel",source); end addEventHandler('pedSyphonVehicle',getRootElement(),pedSyphon); addEvent('pedRefuelVehicle',true); function pedSyphon(v) if getCarFuel(source) <= 0 then outputChatBox("You have no more fuel left.",getVehicleController(v), 255, 0, 0); return end local maxFuel = carFuel[0]; if carFuel[getElementModel(v)] then maxFuel = getFuel[getElementModel(v)]; end if getCarFuel(v) >= maxFuel then outputChatBox("That car is fully refueled.",getVehicleController(v)); return end local n = math.random(100,200)/1000; local left = takeCarFuel(source,n); local total = addCarFuel(v,n); triggerClientEvent("onPedReFuel",source); end addEventHandler('pedRefuelVehicle',getRootElement(),pedSyphon); addEvent('onVehicleRefuel',true); function vehicleRefuel(v,m) if not getElementData(m,'gasStation') then return end if getElementType(v) ~= 'vehicle' then return end if getVehicleType(v) ~= 'Automobile' and getVehicleType(v) ~= 'Bike' and getVehicleType(v) ~= 'Monster Truck' and getVehicleType(v) ~= 'Quad' then return end local driver = getVehicleOccupants(v); if not driver[0] then return end if not isElementWithinMarker(v,m) then return end --### local maxFuel = carFuel[0]; if getPlayerMoney(driver[0]) < 25 then outputChatBox("You can't afford any more fuel.",getVehicleController(v), 255, 0, 0); return end if carFuel[getElementModel(v)] then maxFuel = carFuel[getElementModel(v)]; end if getCarFuel(v) >= maxFuel then return end addCarFuel(v,15); takePlayerMoney(driver[0],25); if getCarFuel(v) >= maxFuel then outputChatBox("Your car has been fully refueled.",getVehicleController(v), 255, 0, 0); return end setTimer(vehicleRefuel,500,1,v,m); end addEventHandler('onVehicleRefuel',getRootElement(),vehicleRefuel); function hitTheMarker(e) setTimer(vehicleRefuel,1500,1,e,source); end addEventHandler('onMarkerHit',getRootElement(),hitTheMarker); function getCarFuel(v) if getElementType(v) == 'vehicle' then if getVehicleType(v) == 'Automobile' or getVehicleType(v) == 'Bike' or getVehicleType(v) == 'Monster Truck' or getVehicleType(v) == 'Quad' then local fuel = getElementData(v,'fuel'); local model = getElementModel(v); if not carFuel[model] then model = 0; end if not fuel then if carFuel[model] then fuel = carFuel[model]; setElementData(v,'fuel',carFuel[model]); else fuel = carFuel[0]; setElementData(v,'fuel',carFuel[0]); end end return fuel; end elseif getElementType(v) == 'player' then local fuel = getElementData(v,'fuel'); if not fuel then setElementData(v,'fuel',0); return 0; end return fuel; end end function addCarFuel(v,a) if getElementType(v) == 'vehicle' then if getVehicleType(v) == 'Automobile' or getVehicleType(v) == 'Bike' or getVehicleType(v) == 'Monster Truck' or getVehicleType(v) == 'Quad' then local fuel = getElementData(v,'fuel'); local model = getElementModel(v); if not carFuel[model] then model = 0; end if not fuel then if carFuel[model] then fuel = carFuel[model]; setElementData(v,'fuel',carFuel[model]); else fuel = carFuel[0]; setElementData(v,'fuel',carFuel[0]); end end fuel = fuel + a; if fuel > carFuel[model] then fuel = carFuel[model]; end setElementData(v,'fuel',fuel); return fuel; end elseif getElementType(v) == 'player' then local fuel = getElementData(v,'fuel'); if not fuel then fuel = 0; end fuel = fuel + a; if fuel > carFuel[-1] then fuel = carFuel[-1]; end setElementData(v,'fuel',fuel); return fuel; end end function takeCarFuel(v,a) if getElementType(v) == 'vehicle' then if getVehicleType(v) == 'Automobile' or getVehicleType(v) == 'Bike' or getVehicleType(v) == 'Monster Truck' or getVehicleType(v) == 'Quad' then local team = getPlayerTeam (source) if getTeamName (team) == "Freeroam" then return end local fuel = getElementData(v,'fuel'); local model = getElementModel(v); if not carFuel[model] then model = 0; end if not fuel then if carFuel[model] then fuel = carFuel[model]; setElementData(v,'fuel',carFuel[model]); else fuel = carFuel[0]; setElementData(v,'fuel',carFuel[0]); end end fuel = fuel - a; if fuel < 0 then fuel = 0; end setElementData(v,'fuel',fuel); return fuel; end elseif getElementType(v) == 'player' then local fuel = getElementData(v,'fuel'); if not fuel then fuel = 0; end fuel = fuel - a;
  21. It needs like, if i write the command then all players who got elementData passenger (metroMatkustaja) true then he hear that sound and message.
×
×
  • Create New...