Jump to content

-.Paradox.-

Members
  • Posts

    1,239
  • Joined

  • Last visited

Everything posted by -.Paradox.-

  1. Hello, How i can use the following to display a "math.random" numbers and make it disappear after 6 seconds? Like example if i killed somebody a text with a random number will appear and after 6 seconds exactly it will disappear, thanks. textDisplayAddObserver textDisplayAddText textDestroyDisplay textDestroyTextItem Server (not tested): function text(player) local test = math.random(100, 200) local serverDisplay = textCreateDisplay() textDisplayAddObserver ( serverDisplay, player ) local serverText = textCreateTextItem ( tonumber(test), 0.5, 0.5 ) textDisplayAddText ( serverDisplay, serverText ) addEventHandler("onPlayerWasted", root, text) setTimer ( text, 6000, 1, textDestroyDisplay ( serverDisplay ) textDestroyTextItem( serverText ) ) end
  2. -.Paradox.-

    Warp

    I have rewrite the whole code, here is it; addEvent("warp", true) addEventHandler("warp", root, function (sourcePlayer, _, playername) if ( not sourcePlayer or not playername ) then return end local x, y, z, r, d = 0, 0, 0, 0, 2.5 local player = getPlayerFromNick ( playername ) if ( player ) then if ( isPlayerInVehicle ( player ) ) then local playervehicle = getPlayerOccupiedVehicle ( player ) local numseats = getVehicleMaxPassengers ( playervehicle ) local i = 0 while ( i < numseats ) do if ( getVehicleOccupant ( playervehicle, i ) ) then i = i + 1 else break end end if ( i < numseats ) then warpPlayerIntoVehicle ( sourcePlayer, playervehicle, i ) else outputChatBox ( "Sorry, the player's vehicle is full (" .. getVehicleName ( playervehicle ) .. " " .. i .. "/" .. numseats .. ")", sourcePlayer ) end else x, y, z = getElementPosition ( player ) r = getPlayerRotation ( player ) interior = getElementInterior ( player ) dimension = getElementDimension ( player ) x = x - ( ( math.cos ( math.rad ( r + 90 ) ) ) * d ) y = y - ( ( math.sin ( math.rad ( r + 90 ) ) ) * d ) setTimer ( setElementInterior, 800, 1, sourcePlayer, interior ) setTimer ( setElementDimension, 900, 1, sourcePlayer, dimension ) setTimer ( setElementPosition, 1000, 1, sourcePlayer, x, y, z ) setTimer ( setPlayerRotation, 1000, 1, sourcePlayer, r ) fadeCamera ( sourcePlayer, false, 1, 0, 0, 0 ) setTimer ( fadeCamera, 1000, 1, sourcePlayer, true, 1 ) end
  3. Make sure that editor resource is stopped
  4. Start Freeroam and Play Gamemode.(just in case if you're using play gamemode, if you're using your own gamemode then run it).
  5. That's because he joined before you crypted the lua files.. Or remove client.lua from meta.xml
  6. -.Paradox.-

    Warp

    :28:attempt to perform arithmetic on global 'd' (a nil value) :29:attempt to perform arithmetic on global 'd' (a nil value)
  7. I think the problem is already solved, I tested my code and it's working...
  8. The following will center gui on all resolutions local x, y = guiGetScreenSize() local Width = ( x - 541 )/2 local Height = ( y - 332 )/2 testWindow = guiCreateWindow(Width, Height, 541, 332, "test window", false) you can replace 541 and 332 with everything you want, i added them just for test
  9. @Golanu, he wants for dxDraw not for GUI. @Newbie i suggest you to create a guiLabel, and then use onClientGUIClick to check when the player click on the label, if you want show a window or a gui element then use guiSetVisible. Example: local myLabel = guiCreateLabel ( x, y, width, height, "text", true ) local myWindow = guiCreateWindow ( x, y, width, height, "Information", true ) guiSetVisible(myWindow, false) function onClick() guiSetVisible(myWindow, true) end addEventHandler("onClientGUIClick", root, onClick)
  10. Server addEvent("giveH",true) addEventHandler("giveH",root, function(plr, vehID) local player = getPlayerFromName(plr or "") local theCurrentVehicle = getPedOccupiedVehicle(player) if player and theCurrentVehicle then if vehID then destroyElement(theCurrentVehicle) local x,y,z = getElementPosition(player) local rx,ry,rz = getElementRotation(player) local vehicle = createVehicle(vehID,x,y,z,rx,ry,rz) warpPedIntoVehicle(player, vehicle) end end end)
  11. Try this, maybe it'll work (not tested) Client function onFuelRender() local fuel = getElementData(localPlayer, "fuel") or 0 if isPedInVehicle ( localPlayer ) and fuel then dxDrawText("Vehicle Fuel: "..tonumber(fuel).."%", 312, 718, 561, 742, tocolor(255, 255, 255, 255), 1.50, "default-bold", "left", "top", false, false, true, false, false) end end addEventHandler("onClientRender", root, onFuelRender) Server: fuelNumber = 100 function fuel () for i, vehicle in ipairs(getElementsByType("vehicle")) do setElementData(vehicle,"fuel",tonumber(fuelNumber)) end end addEventHandler("onPlayerJoin", root, fuel) function decreaseFuel(seat, door) setTimer( function() if ( seat == 0 ) and ( door == 0 ) then local veh = getPedOccupiedVehicle(localPlayer) if ( veh ) and getVehicleController( localPlayer ) then setElementData(veh,"fuel",tonumber(fuelNumber)-1) triggerClientEvent(localPlayer,"onClientRender", root) end end end end,1000,0) addEventHandler("onClientVehicleEnter",getRootElement(),decreaseFuel)
  12. Events onClientGUIClick Functions spawnPlayer Btw i read the whole wiki in 1 hour and only one time. Try to read it carefully and watch to every step
  13. Oh ok then ,thanks, is there another way to do it?
  14. Server addEvent addEventHandler killPed Client getElementHealth triggerServerEvent Here is an example local health = getElementHealth(localPlayer) if health == 5 then triggerServerEvent --etc...
  15. -.Paradox.-

    Warp

    addEventHandler("onClientGUIClick", guiRoot, function() if source == warpPanel.button[2] then local row, column = guiGridListGetSelectedItem(warpPanel.gridlist[1]) if row == -1 then return end local playerName = guiGridListGetItemText(warpPanel.gridlist[1],row,column) local player = getPlayerFromName(playerName) if not playerName then guiGridListRemoveRow(row) return end triggerServerEvent("warp", player,playerName) end end)
  16. If it's Client side then it won't work, If Server side then tell me what debugscript 3 say.
  17. Hello, Can somebody see what's wrong here? Error in debugscript3 ERROR:Test/client:2:Attempt to call global 'downloadFile (a nil value) It suppose to download the car mod and apply it. client function onThisResourceStart ( ) downloadFile ( "579.dff" ) downloadFile ( "579.txd" ) end addEventHandler ( "onClientResourceStart", resourceRoot, onThisResourceStart ) function onDownloadFinish ( file, success ) if ( source == resourceRoot ) then -- if the file relates to this resource if ( success ) then -- if the file was downloaded successfully if ( file == "579.txd" ) then txd = engineImportTXD (file) engineReplaceModel ( txd, 579 ) end else -- if the file wasn't downloaded successfully if ( file == "579.txd" ) then outputChatBox ( "579.txd failed to download" ) end end end end addEventHandler ( "onClientFileDownloadComplete", getRootElement(), onDownloadFinish ) function onDownloadFinish ( file, success ) if ( source == resourceRoot ) then -- if the file relates to this resource if ( success ) then -- if the file was downloaded successfully if ( file == "579.dff" ) then dff = engineLoadDFF (file) engineReplaceModel ( dff, 579 ) end else -- if the file wasn't downloaded successfully if ( file == "579.dff" ) then outputChatBox ( "579.dff failed to download" ) end end end end addEventHandler ( "onClientFileDownloadComplete", getRootElement(), onDownloadFinish ) Meta.xml <meta> <script src="client.lua" type="client"></script> <file src="579.txd" download="false"></file> <file src="579.dff" download="false"></file> </meta> P.S: the files are located in the Test folder ":Test/579.txd" ":Test/579.dff"
  18. Use my Save System addEventHandler ("onPlayerLogin",root, function() loadPedStats( getPlayerAccount(source)) end ) addEventHandler ("onPlayerQuit",root, function() savePedStats( getPlayerAccount(source)) end ) addEventHandler ("onPlayerLogout",root, function(thePreviousAccount) savePedStats( thePreviousAccount ) end ) function savePedStats( Acc) local pedposx,pedposy,pedposz = getElementPosition( source ) local pedrotx,pedroty,pedrotz = getElementRotation( source ) setAccountData(Acc, "pos.x", pedposx) setAccountData(Acc, "pos.y", pedposy) setAccountData(Acc, "pos.z", pedposz) setAccountData(Acc, "rot.x", pedrotx) setAccountData(Acc, "rot.y", pedroty) setAccountData(Acc, "rot.z", pedrotz) setAccountData(Acc, "skin", getPedSkin( source )) setAccountData(Acc, "armor", getPedArmor( source )) setAccountData(Acc, "health", getElementHealth( source )) setAccountData(Acc, "money",getPlayerMoney( source )) for i = 21 , 25 do setAccountData(Acc, "stat."..i , getPedStat(source,i)) end for i = 69 , 79 do setAccountData(Acc, "stat."..i , getPedStat(source,i)) end end function loadPedStats(Acc ) setElementPosition(source,getAccountData(Acc, "pos.x"),getAccountData(Acc, "pos.y"),getAccountData(Acc, "pos.z")) setElementRotation(source,getAccountData(Acc, "rot.x"),getAccountData(Acc, "rot.y"),getAccountData(Acc, "rot.z")) setPedSkin(source,getAccountData(Acc, "skin")) setPedArmor(source,getAccountData(Acc, "armor")) setElementHealth(source,getAccountData(Acc, "health")) setPlayerMoney(source,getAccountData(Acc, "money")) for i = 21 , 25 do setPedStat(source,i,getAccountData(Acc, "stat."..i)) end for i = 69 , 79 do setPedStat(source,i,getAccountData(Acc, "stat."..i)) end end local playerWeapons = { } addEventHandler ( "onPlayerWasted", root, function ( ) if ( not playerWeapons [ source ] ) then playerWeapons [ source ] = { } end for slot = 0, 12 do local weapon = getPedWeapon ( source, slot ) if ( weapon > 0 ) then local ammo = getPedTotalAmmo ( source, slot ) if ( ammo > 0 ) then playerWeapons [ source ] [ weapon ] = ammo end end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) if ( playerWeapons [ source ] ) then for weapon, ammo in pairs ( playerWeapons [ source ] ) do giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) ) end end playerWeapons [ source ] = nil end )
  19. This one only Save the weapons when you Quit and Login. If you want save weapons when you die, then use this: local playerWeapons = { } addEventHandler ( "onPlayerWasted", root, function ( ) if ( not playerWeapons [ source ] ) then playerWeapons [ source ] = { } end for slot = 0, 12 do local weapon = getPedWeapon ( source, slot ) if ( weapon > 0 ) then local ammo = getPedTotalAmmo ( source, slot ) if ( ammo > 0 ) then playerWeapons [ source ] [ weapon ] = ammo end end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) if ( playerWeapons [ source ] ) then for weapon, ammo in pairs ( playerWeapons [ source ] ) do giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) ) end end playerWeapons [ source ] = nil end ) Made by Castillo
  20. -.Paradox.-

    Warp

    Hello, I made a warp panel , but when i click warp, i'm not warped to the selected player, No errors in debugscript 3, hope somebody help me with this. Thanks Server; addEvent("warp", true) addEventHandler("warp", root, function (source, playername) local player = getPlayerFromName(playername or "") if player then --local x,y,z = getElementPosition(player) if ( isPedInVehicle(player) ) then local playerVehicle = getPedOccupiedVehicle ( player ) local numseats = getVehicleMaxPassengers ( playerVehicle ) local i = 0 while ( i < numseats ) do if ( getVehicleOccupant ( playerVehicle, i ) ) then i = i + 1 else break end end if ( i < numseats ) then warpPedIntoVehicle ( source, playerVehicle, i ) else outputChatBox ( "Sorry, the player's vehicle is full (" .. getVehicleName ( playerVehicle ) .. " " .. i .. "/" .. numseats .. ")", source ) end else x, y, z = getElementPosition ( player ) r = getPedRotation ( player ) interior = getElementInterior ( player ) dimension = getElementDimension ( player ) x = x - ( ( math.cos ( math.rad ( r + 90 ) ) ) * d ) y = y - ( ( math.sin ( math.rad ( r + 90 ) ) ) * d ) setTimer ( setElementInterior, 800, 1, source, interior ) setTimer ( setElementDimension, 900, 1, source, dimension ) setTimer ( setElementPosition, 1000, 1, source, x, y, z ) setTimer ( setPedRotation, 1000, 1, source, r ) fadeCamera ( source, false, 1, 0, 0, 0 ) setTimer ( fadeCamera, 1000, 1, source, true, 1 ) --setElementPosition(source, x,y,z) end end end)
×
×
  • Create New...