Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. You have an extra 'end' at the end of your script. Also, you can't use "require" on MTA, and I think is not required neither, since you can use callRemote to do it. local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- encoding function base64enc(data) return ((data:gsub('.', function(x) local r,b='',x:byte() for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end return r; end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x) if (#x < 6) then return '' end local c=0 for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end return b:sub(c+1,c+1) end)..({ '', '==', '=' })[#data%3+1]) end -- decoding function base64dec(data) data = string.gsub(data, '[^'..b..'=]', '') return (data:gsub('.', function(x) if (x == '=') then return '' end local r,f='',(b:find(x)-1) for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end return r; end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x) if (#x ~= -- s8) --> then return '' end local c=0 for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end return string.char(c) end)) end function validateOnWeb(user, pass) socket = require("socket") http = require("socket.http") username = base64enc(user) password = base64enc(pass) response = http.request("http://URL/validate.php?user=" .. username .. "&pass=" .. password) if(string.sub(response, 0, 1) == "0") then return true end return false end function PlayerLogin(username,password,checksave) if not (username == "") then if not (password == "") then local account = getAccount ( username, password ) if ( account ~= false and validateOnWeb(username, password)) then logIn(source, account, password) triggerClientEvent (source,"hideLoginWindow",getRootElement()) if checksave == true then triggerClientEvent(source,"saveLoginToXML",getRootElement(),username,password) else triggerClientEvent(source,"resetSaveXML",getRootElement(),username,password) end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Login","Wrong username and/or password!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Login","Please enter your password!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Login","Please enter your username!") end end addEvent("onRequestLogin",true) addEventHandler("onRequestLogin",getRootElement(),PlayerLogin) function registerPlayer(username,password,passwordConfirm) if not (username == "") then if not (password == "") then if not (passwordConfirm == "") then if password == passwordConfirm then if(validateOnWeb(username, password) then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then outputChatBox ("#FF0000* #00FF00You have sucessfuly registered! [username: #FFFFFF" .. username .. " #00FF00| Password: #FFFFFF" .. password .. "#00FF00 ]",source,255,255,255,true ) else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","An unknown error has occured! Please choose a different username/password and try again.") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","An account with this username already exists!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Please register on webiste!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Passwords do not match!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Please confirm your password!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Please enter a password!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Please enter a username you would like to register with!") end end addEvent("onRequestRegister",true) addEventHandler("onRequestRegister",getRootElement(),registerPlayer)
  2. There's one called "MTA paradise" which is a free Roleplay game mode. https://github.com/mabako/mta-paradise
  3. Castillo

    Attach

    Do you get errors on the debugscript?
  4. We don't give support with leaked scripts. Topic locked.
  5. I'm afraid that I still don't understand, GUIeditor only let's you draw the interface, it doesn't make it functional.
  6. Mind explaining a little more? such as, what is the problem? do you get any error?
  7. I don't really understand what do you mean by "item".
  8. Updating is not requring, level and experience are saved as element data, so you can just use the data name of them which is: "exp" and "level". exports [ "scoreboard" ]:addScoreboardColumn ( "exp" ) exports [ "scoreboard" ]:addScoreboardColumn ( "level" )
  9. Castillo

    Runcode

    Te falta un parentesis para cerrar getPlayerFromName.
  10. El lag es porque la conexion de internet es muy mala, o tenes scripts que usan muchos recursos.
  11. Castillo

    Ayuda bindKey

    function getItemInfo ( ) local px, py, pz, tx, ty, tz, dist local px, py, pz = getCameraMatrix ( ) for _, v in ipairs ( getElementsByType ( "object" ) ) do if getElementData ( v, "Municion" ) then local tx, ty, tz = getElementPosition ( v ) local dist = math.sqrt ( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if ( dist < 30.0 ) then if isLineOfSightClear ( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false, localPlayer ) then local sx, sy, sz = getElementPosition ( v ) local x, y = getScreenFromWorldPosition ( sx + 0.9, sy, sz + 0.7, 100, false ) if ( x and y ) then local item = getElementModel ( v ) outputChatBox ( tostring ( item ) ) local distance = getDistanceBetweenPoints3D ( px, py, pz, sx, sy, sz ) dxDrawText ( "item: 1234", x, y+10, x, y, tocolor(245,245,245), 0.60 + ( 15 - dist ) * 0.02, "bankgothic" ) dxDrawText ( "Ammo: 12345", x, y-5, x, y+100, tocolor(245,245,245), 0.60 + ( 20 - dist ) * 0.02, "bankgothic" ) end end end end end end addEventHandler ( "onClientRender", root, getItemInfo )
  12. Podes usar DX drawing para crear un texto sobre su cabeza.
  13. Castillo

    Ayuda bindKey

    Estas checkeando si "v" es igual a 358, pero "v" es un elemento, tenes que obtener el modelo del objeto con getElementModel
  14. Wrong, is server side when you use it to set the player weapon ammo, and client side for custom weapons.
  15. Si lo dejas con: "resourceRoot", entonces se creara la imagen al morir cualquier jugador, no solo el cliente.
  16. Usa el evento onClientPlayerWasted.
  17. Castillo

    Ayuda bindKey

    Ah, me olvide de cambiar unas variables. local inColShape = { } local weapons = { } function bindStart ( ) for _, v in ipairs ( getElementsByType ( "player" ) ) do bindKey ( v, "n", "down", pickupWeapon ) end end addEventHandler ( "onResourceStart", resourceRoot, bindStart ) function login ( ) bindKey ( source, "n", "down", pickupWeapon ) end addEventHandler ( "onPlayerLogin", getRootElement(), login ) function pullItem ( item, ammo ) local x, y, z = getElementPosition ( source ) local colshape = createColTube ( x, y, z - 1, 1, 1 ) weapons [ colshape ] = createObject ( 358, x, y, z - 1, 70, 0, 0 ) setElementData ( colshape, "Arma", 34 ) setElementData ( colshape, "Municion", ammo ) takeWeapon ( source, 34 ) addEventHandler ( "onColShapeHit", colshape, onColShape ) addEventHandler ( "onColShapeLeave", colshape, onColShape ) end addEvent ( "onPlayerPullSniper", true ) addEventHandler ( "onPlayerPullSniper", getRootElement(), pullItem ) function onColShape ( hitElement, matchDim ) if ( getElementType ( hitElement ) == "player" and matchDim ) then if ( eventName == "onColShapeHit" ) then inColShape [ hitElement ] = source else inColShape [ hitElement ] = nil end end end function pickupWeapon ( player ) local colshape = inColShape [ player ] if isElement ( colshape ) then if isElementWithinColShape ( player, colshape ) then outputChatBox ( "/recoger", player, 0, 255, 255 ) giveWeapon ( player, getElementData ( colshape, "Arma" ), getElementData ( colshape, "Municion" ) ) destroyElement ( weapons [ colshape ] ) weapons [ colshape ] = nil destroyElement ( colshape ) inColShape [ player ] = nil end end end
  18. Castillo

    Dudas

    addCommandHandler ( "yo", function ( thePlayer, _, ... ) local msg = table.concat ( { ... }, " " ) if ( msg ~= "" ) then outputChatBox ( "* ".. getPlayerName ( thePlayer ) .." ".. msg, root, 255, 0, 255 ) end end )
  19. You can find a resource which lets you do that on this site: http://crystalmv.net84.net/pages/scripts.php
  20. Castillo

    Ayuda bindKey

    Pero te da el arma y pone ese mensaje en el chat?
×
×
  • Create New...