Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. Use this and tell me what does it say when you drift: exports.scoreboard:addScoreboardColumn ( 'Drift Rank' ) addEventHandler ( "onResourceStart", resourceRoot, function ( ) for _, player in ipairs ( getElementsByType ( "player" ) ) do local account = getPlayerAccount ( player ) if ( not isGuestAccount ( account ) ) then local driftPoints = tonumber ( getAccountData ( account, "Best Drift" ) ) or 0 checkDrift ( player, driftPoints ) end end end ) addEventHandler ( "onPlayerLogin", root, function ( _, account ) local driftPoints = tonumber ( getAccountData ( account, "Best Drift" ) ) or 0 checkDrift ( source, driftPoints ) end ) addEvent ( "onPlayerGotBetterDrift", true ) addEventHandler ( "onPlayerGotBetterDrift", root, function ( value ) outputChatBox ( "onPlayerGotBetterDrift: You got ".. tostring ( value ), source ) checkDrift ( source, value ) end ) function checkDrift ( thePlayer, value ) if ( value >= 0 ) and ( value <= 29999 ) then setElementData ( thePlayer, "Drift Rank", "Sucky" ) elseif ( value >= 30000 ) and ( value <= 89999 ) then setElementData ( thePlayer, "Drift Rank", "Newbie" ) elseif ( value >= 90000 ) and ( value <= 149999 ) then setElementData ( thePlayer, "Drift Rank", "Grandpa" ) end end
  2. Show us how are you inserting the data.
  3. Castillo

    ayuda peds

    No hace falta crear otra funcion, podes hacer: setTimer ( giveWeapon, 600, 1, elped, 31, 200, true )
  4. Castillo

    ayuda peds

    Dale el arma con un timer de 1 segundo despues de crearlo, habia un problema si se la dabas justo cuando lo creas.
  5. Es verdad, fue un error al escribir rapido.
  6. You got 30000 drift points? because that's the next rank.
  7. Replace client side ( drft.lua ) with this one: --these are the banned vehicle ids where you cannot get drift points. local BannedIDs = { 432, 532 } local rootElem = getRootElement() local thisRoot = getResourceRootElement(getThisResource()) local player = getLocalPlayer() local vehicle local size = 1.2 local modo = 0.01 local score = 0 local screenScore = 0 local tick local idleTime local multTime local driftTime local Yellow = tocolor(255,232,25) local Red = tocolor(234,0,3) local TempCol = Yellow local mult = 1 local tablamult = {350,1400,4200,11200} local anterior = 0 local mejor = 0 local total = 0 local global_mejor = 0 local global_nombre = "N/A" local screenWidth, screenHeight = guiGetScreenSize() local x1,y1,x2,y2 = screenWidth*0.2,screenHeight*0.1,screenWidth*0.8,screenHeight*0.8 addEventHandler("onClientResourceStart", thisRoot, function() addEventHandler("onClientRender", rootElem, showText) outputChatBox("Waiting for server drift data...") triggerServerEvent("driftClienteListo", rootElem, player) end ) addEventHandler("onClientResourceStop", thisRoot, function() removeEventHandler("onClientRender", rootElem, showText) end ) function isValidVehicle() local temp = getPedOccupiedVehicle(player) if not temp or getVehicleOccupant(temp,0) ~= player or getVehicleType(temp) ~= "Automobile" then return false end local vehID = getElementModel(temp) for k,v in ipairs(BannedIDs) do if vehID == v then return false end end return temp end function showText() dxDrawText(string.format("Best Drift: %s - %d",global_nombre,global_mejor),44,screenHeight-43,screenWidth,screenHeight,Yellow,1,"pricedown") vehicle = isValidVehicle() if not vehicle then return end if size > 1.3 then modo = -0.01 elseif size < 1.2 then modo = 0.01 end size = size + modo tick = getTickCount() local angulo,velocidad = angle() local tempBool = tick - (idleTime or 0) < 750 if not tempBool and score ~= 0 then anterior = score setElementData(player, "Last Drift", anterior) total = total+anterior setElementData(player, "Total Drift", total) if score > mejor then mejor = score setElementData(player, "Best Drift", mejor) end if ( score > 0 ) then triggerServerEvent ( "updatePlayerDrift", localPlayer, score ) end triggerEvent("onVehicleDriftEnd", rootElem, tick-driftTime-750) score = 0 end if angulo ~= 0 then if score == 0 then triggerEvent("onVehicleDriftStart", rootElem) driftTime = tick end if tempBool then score = score + math.floor(angulo*velocidad)*mult else score = math.floor(angulo*velocidad)*mult end if TempCol == Red then TempCol = Yellow end screenScore = score idleTime = tick end local temp2 = string.format("Factor: X%d\n%s",mult,mult~=5 and string.format("Gain X%d with %d",mult+1,tablamult[mult]) or "MAX") dxDrawText(temp2, 20,155,screenWidth,screenHeight, Yellow, 1.2, "sans","left","top", false,true,false) if velocidad <= 0.3 and mult ~= 1 then dxDrawText("\n\nToo Slow!", 20,155,screenWidth,screenHeight, Yellow, 1.2, "sans","left","top", false,true,false) end if tick - (idleTime or 0) < 3000 then local temp = "DRIFT" if score >= 100000 then temp = "DRIFT\n\nDrift King!" elseif score >= 50000 then temp = "DRIFT\n\nInsane Drift!" elseif score >= 20000 then temp = "DRIFT\n\nOutrageous!" elseif score >= 15000 then temp = "DRIFT\n\nColossal!" elseif score >= 7000 then temp = "DRIFT\n\nSuberb!" elseif score >= 3000 then temp = "DRIFT\n\nGreat Drift!" elseif score >= 1000 then temp = "DRIFT\n\nGood Drift!" end dxDrawText(temp, x1,y1,x2,y2, TempCol, 2.2, "sans","center","top", false,true,false) dxDrawText(string.format("\n%d",screenScore), x1,y1-10,x2,y2, TempCol, size, "pricedown","center","top", false,true,false) end end function angle() local vx,vy,vz = getElementVelocity(vehicle) local modV = math.sqrt(vx*vx + vy*vy) if not isVehicleOnGround(vehicle) then return 0,modV end local rx,ry,rz = getElementRotation(vehicle) local sn,cs = -math.sin(math.rad(rz)), math.cos(math.rad(rz)) local deltaT = tick - (multTime or 0) if mult~= 1 and modV <= 0.3 and deltaT > 750 then mult = mult-1 multTime = tick elseif deltaT > 1500 then local temp = 1 if score >= 11200 then temp = 5 elseif score >= 4200 then temp = 4 elseif score >= 1400 then temp = 3 elseif score >= 350 then temp = 2 end if temp>mult then mult = temp multTime = tick end end if modV <= 0.2 then return 0,modV end --speed over 40 km/h local cosX = (sn*vx + cs*vy)/modV if cosX > 0.966 or cosX < 0 then return 0,modV end --angle between 15 and 90 degrees return math.deg(math.acos(cosX))*0.5, modV end addEvent("driftCarCrashed", true) addEventHandler("driftCarCrashed", rootElem, function() if score ~= 0 then score = 0 mult = 1 TempCol = Red triggerEvent("onVehicleDriftEnd", rootElem, 0) end end ) addEvent("driftActualizarRecord", true) addEventHandler("driftActualizarRecord", rootElem, function(score, name) global_mejor = score global_nombre = name end ) function resetScore() anterior,mejor,total = 0,0,0 setElementData(player, "Last Drift", anterior) setElementData(player, "Total Drift", total) setElementData(player, "Best Drift", mejor) end addEvent("driftResetAllScores", true) addEventHandler("driftResetAllScores", rootElem, resetScore) addCommandHandler("resetdrift", resetScore) function checkPuntaje() if total > global_mejor then triggerServerEvent("driftNuevoRecord", rootElem, total, getPlayerName(player)) end end addEventHandler("onClientPlayerFinish", rootElem, checkPuntaje) addEventHandler("onClientPlayerOutOfTime", rootElem, checkPuntaje)
  8. You added a parentheses at the end of the 'checkDrift' function, that was causing the script to don't start. exports.scoreboard:addScoreboardColumn ( 'Drift Rank' ) addEventHandler ( "onResourceStart", resourceRoot, function ( ) for _, player in ipairs ( getElementsByType ( "player" ) ) do local account = getPlayerAccount ( player ) if ( not isGuestAccount ( account ) ) then local driftPoints = tonumber ( getAccountData ( account, "Best Drift" ) ) or 0 checkDrift ( player, driftPoints ) end end end ) addEventHandler ( "onPlayerLogin", root, function ( _, account ) local driftPoints = tonumber ( getAccountData ( account, "Best Drift" ) ) or 0 checkDrift ( source, driftPoints ) end ) addEvent ( "onPlayerGotBetterDrift", true ) addEventHandler ( "onPlayerGotBetterDrift", root, function ( value ) checkDrift ( source, value ) end ) function checkDrift ( thePlayer, value ) if ( value >= 0 ) and ( value <= 29999 ) then setElementData ( thePlayer, "Drift Rank", "Sucky" ) elseif ( value >= 30000 ) and ( value <= 89999 ) then setElementData ( thePlayer, "Drift Rank", "Newbie" ) elseif ( value >= 90000 ) and ( value <= 149999 ) then setElementData ( thePlayer, "Drift Rank", "Grandpa" ) end end
  9. Show me the script where you put the scoreboard column creation.
  10. Castillo

    Moving Chat

    You could try this chat system: https://community.multitheftauto.com/in ... ls&id=6380
  11. local countries = { [ "CO" ] = true, [ "BR" ] = true, [ "CN" ] = true } function paises ( ) local pais = exports.admin:getPlayerCountry ( source ) or "N/A" if ( countries [ pais ] ) then kickPlayer ( source, "Pais No Permitido" ) end end addEventHandler ( "onPlayerJoin", getRootElement(), paises ) Con eso podes agregar mas paises facilmente.
  12. Do you have this added? exports.scoreboard:addScoreboardColumn ( 'Drift Rank' )
  13. Castillo

    Moving Chat

    You can't move the chat, you'll have to create your own chat system.
  14. Castillo

    Twitter

    You can't use "require" in MTA.
  15. You have to store all the objects and colshapes in a table, else you won't be able to destroy them without problems.
  16. Replace your entire drift resource with this one: drft.lua: --these are the banned vehicle ids where you cannot get drift points. local BannedIDs = { 432, 532 } local rootElem = getRootElement() local thisRoot = getResourceRootElement(getThisResource()) local player = getLocalPlayer() local vehicle local size = 1.2 local modo = 0.01 local score = 0 local screenScore = 0 local tick local idleTime local multTime local driftTime local Yellow = tocolor(255,232,25) local Red = tocolor(234,0,3) local TempCol = Yellow local mult = 1 local tablamult = {350,1400,4200,11200} local anterior = 0 local mejor = 0 local total = 0 local global_mejor = 0 local global_nombre = "N/A" local screenWidth, screenHeight = guiGetScreenSize() local x1,y1,x2,y2 = screenWidth*0.2,screenHeight*0.1,screenWidth*0.8,screenHeight*0.8 addEventHandler("onClientResourceStart", thisRoot, function() addEventHandler("onClientRender", rootElem, showText) outputChatBox("Waiting for server drift data...") triggerServerEvent("driftClienteListo", rootElem, player) end ) addEventHandler("onClientResourceStop", thisRoot, function() removeEventHandler("onClientRender", rootElem, showText) end ) function isValidVehicle() local temp = getPedOccupiedVehicle(player) if not temp or getVehicleOccupant(temp,0) ~= player or getVehicleType(temp) ~= "Automobile" then return false end local vehID = getElementModel(temp) for k,v in ipairs(BannedIDs) do if vehID == v then return false end end return temp end function showText() dxDrawText(string.format("Best Drift: %s - %d",global_nombre,global_mejor),44,screenHeight-43,screenWidth,screenHeight,Yellow,1,"pricedown") vehicle = isValidVehicle() if not vehicle then return end if size > 1.3 then modo = -0.01 elseif size < 1.2 then modo = 0.01 end size = size + modo tick = getTickCount() local angulo,velocidad = angle() local tempBool = tick - (idleTime or 0) < 750 if not tempBool and score ~= 0 then anterior = score setElementData(player, "Last Drift", anterior) total = total+anterior setElementData(player, "Total Drift", total) if score > mejor then mejor = score setElementData(player, "Best Drift", mejor) end triggerEvent("onVehicleDriftEnd", rootElem, tick-driftTime-750) score = 0 end if angulo ~= 0 then if score == 0 then triggerEvent("onVehicleDriftStart", rootElem) driftTime = tick end if tempBool then score = score + math.floor(angulo*velocidad)*mult else score = math.floor(angulo*velocidad)*mult end if TempCol == Red then TempCol = Yellow end screenScore = score idleTime = tick end local temp2 = string.format("Factor: X%d\n%s",mult,mult~=5 and string.format("Gain X%d with %d",mult+1,tablamult[mult]) or "MAX") dxDrawText(temp2, 20,155,screenWidth,screenHeight, Yellow, 1.2, "sans","left","top", false,true,false) if velocidad <= 0.3 and mult ~= 1 then dxDrawText("\n\nToo Slow!", 20,155,screenWidth,screenHeight, Yellow, 1.2, "sans","left","top", false,true,false) end if tick - (idleTime or 0) < 3000 then local temp = "DRIFT" if score >= 100000 then temp = "DRIFT\n\nDrift King!" elseif score >= 50000 then temp = "DRIFT\n\nInsane Drift!" elseif score >= 20000 then temp = "DRIFT\n\nOutrageous!" elseif score >= 15000 then temp = "DRIFT\n\nColossal!" elseif score >= 7000 then temp = "DRIFT\n\nSuberb!" elseif score >= 3000 then temp = "DRIFT\n\nGreat Drift!" elseif score >= 1000 then temp = "DRIFT\n\nGood Drift!" end dxDrawText(temp, x1,y1,x2,y2, TempCol, 2.2, "sans","center","top", false,true,false) dxDrawText(string.format("\n%d",screenScore), x1,y1-10,x2,y2, TempCol, size, "pricedown","center","top", false,true,false) end end function angle() local vx,vy,vz = getElementVelocity(vehicle) local modV = math.sqrt(vx*vx + vy*vy) if not isVehicleOnGround(vehicle) then return 0,modV end local rx,ry,rz = getElementRotation(vehicle) local sn,cs = -math.sin(math.rad(rz)), math.cos(math.rad(rz)) local deltaT = tick - (multTime or 0) if mult~= 1 and modV <= 0.3 and deltaT > 750 then mult = mult-1 multTime = tick elseif deltaT > 1500 then local temp = 1 if score >= 11200 then temp = 5 elseif score >= 4200 then temp = 4 elseif score >= 1400 then temp = 3 elseif score >= 350 then temp = 2 end if temp>mult then mult = temp multTime = tick end end if modV <= 0.2 then return 0,modV end --speed over 40 km/h local cosX = (sn*vx + cs*vy)/modV if cosX > 0.966 or cosX < 0 then return 0,modV end --angle between 15 and 90 degrees return math.deg(math.acos(cosX))*0.5, modV end addEvent("driftCarCrashed", true) addEventHandler("driftCarCrashed", rootElem, function() if score ~= 0 then score = 0 mult = 1 TempCol = Red triggerEvent("onVehicleDriftEnd", rootElem, 0) end end ) addEvent("driftActualizarRecord", true) addEventHandler("driftActualizarRecord", rootElem, function(score, name) global_mejor = score global_nombre = name end ) function resetScore() anterior,mejor,total = 0,0,0 setElementData(player, "Last Drift", anterior) setElementData(player, "Total Drift", total) setElementData(player, "Best Drift", mejor) end addEvent("driftResetAllScores", true) addEventHandler("driftResetAllScores", rootElem, resetScore) addCommandHandler("resetdrift", resetScore) function checkPuntaje() if total > global_mejor then triggerServerEvent("driftNuevoRecord", rootElem, total, getPlayerName(player)) end if ( total > 0 ) then triggerServerEvent ( "updatePlayerDrift", localPlayer, total ) end end addEventHandler("onClientPlayerFinish", rootElem, checkPuntaje) addEventHandler("onClientPlayerOutOfTime", rootElem, checkPuntaje) drft_server.lua: local root = getRootElement() local thisResourceRoot = getResourceRootElement(getThisResource()) local drift_records = {} local drift_mejor = 0 local drift_nombre = "N/A" addEventHandler ( "onResourceStart", thisResourceRoot, function() call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Best Drift") call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Last Drift") call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Total Drift") executeSQLCreateTable("recordsDrift","pista TEXT, nombre TEXT, score INTEGER") addEvent("driftClienteListo", true) addEventHandler("driftClienteListo", root, function(player) triggerClientEvent(player, "driftActualizarRecord", root, drift_mejor, drift_nombre) if drift_mejor == 0 then outputChatBox("There's no record set on this map", player) else outputChatBox(string.format("The current record is %d points (%s)", drift_mejor, drift_nombre), player) end end) end ) addEventHandler ( "onResourceStop", thisResourceRoot, function() call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Best Drift") call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Last Drift") call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Total Drift") end ) addEventHandler ( "onGamemodeMapStart", root, function(mapResource) local mapname = getResourceInfo(mapResource, "name") or getResourceName(mapResource) local command = string.format("pista='%s'",mapname) local record = executeSQLSelect("recordsDrift","nombre, score",command) if #record == 0 then executeSQLInsert("recordsDrift",string.format("'%s', 'N/A', 0",mapname)) drift_mejor = 0 drift_nombre = "N/A" else drift_mejor = record[1]["score"] drift_nombre = record[1]["nombre"] end triggerClientEvent(root, "driftActualizarRecord", root, drift_mejor, drift_nombre) triggerClientEvent(root, "driftResetAllScores", root) if drift_mejor == 0 then outputChatBox("There's no record set on this map") else outputChatBox(string.format("The current record is %d points (%s)", drift_mejor, drift_nombre)) end end) addEventHandler ( "onGamemodeMapStop", root, function(mapResource) local mapname = getResourceInfo(mapResource, "name") or getResourceName(mapResource) if not mapname then return end local command = string.format("pista='%s'",mapname) executeSQLUpdate("recordsDrift",string.format("nombre = '%s', score = %d", drift_nombre, drift_mejor), command) end) addEventHandler("onVehicleDamage", root, function() thePlayer = getVehicleOccupant(source, 0) if thePlayer then triggerClientEvent(thePlayer, "driftCarCrashed", root, source) end end) addEvent("driftNuevoRecord", true) addEventHandler("driftNuevoRecord", root, function(score, name) if score > drift_mejor then outputChatBox(string.format("New drift record! (%d points) (%s)",score,name)) drift_mejor = score drift_nombre = name triggerClientEvent(root, "driftActualizarRecord", root, drift_mejor, drift_nombre) end end) addEvent ( "updatePlayerDrift", true ) addEventHandler ( "updatePlayerDrift", root, function ( value ) local account = getPlayerAccount ( client ) if ( not isGuestAccount ( account ) ) then local driftPoints = tonumber ( getAccountData ( account, "Best Drift" ) ) or 0 if ( value > driftPoints ) then setAccountData ( account, "Best Drift", value ) triggerEvent ( "onPlayerGotBetterDrift", client, value ) end end end ) And then you can use your drift rank script like this: addEventHandler ( "onPlayerLogin", root, function ( _, account ) local driftPoints = tonumber ( getAccountData ( account, "Best Drift" ) ) or 0 checkDrift ( source, driftPoints ) end ) addEvent ( "onPlayerGotBetterDrift", true ) addEventHandler ( "onPlayerGotBetterDrift", root, function ( value ) checkDrift ( source, value ) end ) function checkDrift ( thePlayer, value ) if ( value >= 0 ) and ( value <= 29999 ) then setElementData ( thePlayer, "Drift Rank", "Sucky" ) elseif ( value >= 30000 ) and ( value <= 89999 ) then setElementData ( thePlayer, "Drift Rank", "Newbie" ) elseif ( value >= 90000 ) and ( value <= 149999 ) then setElementData ( thePlayer, "Drift Rank", "Grandpa" ) end end
  17. items = { { "Tire!", 1073, -1428.4814453125, 2666.4931640625, 55.6875}, { "Engine!", 929, -1425.5595703125, 2654.69140625, 55.6875}, { "Hamburguer!", 2768, -1411.2607421875, 2635.3916015625, 55.6875}, } function mainFunction ( ) local tiempo = 5000 setTimer ( function ( ) for _, v in ipairs ( items ) do object = createObject ( v [ 2 ], v [ 3 ], v [ 4 ], v [ 5 ], 0, 0, math.random ( 0, 360 ) ) setElementData ( object, v [ 1 ], true ) end end ,tiempo, 1 ) end mainFunction ( )
  18. You want to save the new drift if it's better than the one you got saved?
  19. Post the drift resource you are using.
  20. Si es posible, podes usar la funcion exportada del admin panel de lil toady ( el que viene con el MTA ) getPlayerCountry para obtener el codigo de su pais.
  21. Yes, you have to save the drift, obviously.
×
×
  • Create New...