Jump to content

Jumba'

Members
  • Posts

    254
  • Joined

  • Last visited

Posts posted by Jumba'

  1. Just post the whole code.

    And that snippet you just wrote fails epically, after end you're supposed to put a ) to close the command handler, thought I have no idea if that's what you want.

  2. We did not ban by ip, we banned by serial, but he changed his mac adreas which changed his serial

    Ban his entire IP range :P

  3. Help me pls. I cant use spawnPlayer function. It not work. In console write:

    [12:07:31] WARNING: login_server.lua: Bad 'player' pointer @ 'spawnPlayer'(1) - Line: 72

    Look, eh, on the client-side file make sure its triggered with the player as the source

    so it'd be

    triggerServerEvent ( "serverRegister", getLocalPlayer(), newUsername, newPassword, newMail )
    

    It should work.

  4. Your lucky I got some exams tomorrow, this presents a perfect opportunity to procrastinate! :D

    Try this ... you add the objectID, ZYX, time to open, move to XYZ in the gates table, I've already added your own two gates in it. So basically to open the first gate you do /open 1, and for the second /open 2, etc.

    Same with /close.

    I'd recommend adding a colcircle around the gate tho since it's a bit unrealistic to open a gate in SF while riding in LS :P, or just check the distance between GetDistanceBetweenPoints3D using the gate position as one point and the players position as the other.

    Oh, and I haven't tested it, but I suppose I'd work :/

    -- First thing is to create a table to hold all the coordinates for the gates.
    -- In the gates table there tables that contain the info for one gate
    -- { objectID, CoordX, CoordY, CoordZ, Time to move gate in ms, moveToCoordZ, moveToCoordY, moveToCoordZ )
    local gates =  {
    { 969, 209.0489654541, 1875.4265136719, 12.140625, 3000, 200.65399169922, 1875.3364257813, 12.140625 },
    { 3109, 226.6572265625, 1858.30859375, 14.64695930481, 3000, 226.6572265625, 1858.30859375, 11.64695930481 }
    }
     
    local gate = { }	-- this is where we store the gate elements.
     
    addEventHandler ( "onResourceStart", getResourceRootElement(),
    function ( )
    for i, tbl in ipairs ( gates ) do -- when the resource start we loop over the gates table
    		gate[i] = createObject ( tbl[1], tbl[2], tbl[3], tbl[4] ) -- we create objects, the numbers 1-4 are the location of the objectID and the XYZ coords. ( see above )
    end
    end
    )
     
    addCommandHandler ( "open", 
    function ( source, command, gate )
    if tonumber ( gate ) then -- if its not a number we cant use it.
    local i = tonumber ( gate )
    if gate[i] then -- if that gate exists we open it up
    moveObject ( gate[i], gates[i][5], gates[i][6], gates[i][7], gates[i][8] ) -- we open it to the XYZ coords in x amount of seconds, 5 - 8 in the table.
    else
    outputChatBox ( "Gate not found", source )
    end	
    else
    outputChatBox ( "Syntax is /" .. command .. " , with gate being a number.", source )
    end
    end
    )	
     
     
    addCommandHandler ( "close", 
    function ( source, command, gate )
    if tonumber ( gate ) then
    local i = tonumber ( gate )
    if gate[i] then
    moveObject ( gate[i], gates[i][5], gates[i][2], gates[i][3], gates[i][4] )  -- same as above, but since we're closing it (going back to begin position) we use the 2-4 XYZ.
    else
    outputChatBox ( "Gate not found", source )
    end	
    else
    outputChatBox ( "Syntax is /" .. command .. " , with gate being a number.", source )
    end
    end
    )
    

  5. I tried to make my ped accelerate in a vehicle, but i get this error in my console:

    attempt to call global 'setPedControlState' (a nil value)

    The Code:

    ped = createPed( tonumber( id ), x, y, z );
    local veh = createVehicle(400, x, y-4, z);
    warpPedIntoVehicle ( ped, veh )
    setPedControlState (ped, "accelerate", true)
    

    You sure the script is client-side?

    -edit-

    It's not, since warpPedIntoVehicle worked and that's server-side only.

    You have to create the peds, warp em into the vehicles then use the event system to transfer them to the clients.

    There you can use setPedControlState

  6. ....

    Is there a tool similar to the "netgraph" in CSS that would allow for server performance monitoring?

    No, but there was a command you could use in game to display server performance. If I remember correctly, it was /shownet <1 or 0> (1 to show, 0 to hide).

    I think it's /netstat 1

    That's what I use to get the connection data.

  7. Gamesnert has provided a pretty good overview, but the I don't agree with his conclusions.

    Everything should be server side if it can be. You should aim to put purely 'presentational' stuff client-side. You should avoid trusting the client at all, if you possibly can. Any interface you provide between the server and client should be as minimal as possible - don't let the client call any server function for example. It may be convenient for you - but it's a big risk.

    This is from a theoretical point of view, in practice, you'll have to make compromises probably.

    What do you mean with not letting the client call any server function?

    What should I when I have to check if the username/password is in the database then? Or am I understanding you wrong?

  8. At this moment, when i started the gamemode in server, i had no errors. Though when i go in-game, iam confronted with a black screen with the only message being "Welcome to My Server."

    Did you check for errors using /debugscript 3 or just in the server console? since not everything gets reported to the console.

  9. Only client-side. :S

    I hate when It's only working at client-side.

    And luac5.1.exe is not working, it's getting better and better! X.X

    Well did the client-side version of the script work?

  10. Try this
    function teleHome ( source, command )
    local veh = getPedOccupiedVehicle(source)
    local dimension = getElementDimension(source)
    if dimension == 0 then
    if not veh then
    setElementPosition( source, 405.25030517578, 2436.3159179688, 17.747388839722)
    else
    setElementPosition( veh, 423.39221191406, 2522.8637695313, 16.484375)
    end
    end
    end
    addCommandHandler ( "/home", teleHome)
    

    Doesn't work.

    Still bad argument @ getElementDimension. :(

    Is the script client-side or serverside? If its client side then try this.

    function teleHome ( )
    local player = getLocalPlayer()
    local veh = getPedOccupiedVehicle(player)
    local dimension = getElementDimension(player)
    if dimension == 0 then
    if not veh then
    setElementPosition( player, 405.25030517578, 2436.3159179688, 17.747388839722)
    else
    setElementPosition( veh, 423.39221191406, 2522.8637695313, 16.484375)
    end
    end
    end
    addCommandHandler ( "/home", teleHome)
    

  11. Try this

    function teleHome ( source, command )
    local veh = getPedOccupiedVehicle(source)
    local dimension = getElementDimension(source)
    if dimension == 0 then
    if not veh then
    setElementPosition( source, 405.25030517578, 2436.3159179688, 17.747388839722)
    else
    setElementPosition( veh, 423.39221191406, 2522.8637695313, 16.484375)
    end
    end
    end
    addCommandHandler ( "/home", teleHome)
    

  12. function Script_onResourceLoad ( resource )
    if ( resource == getThisResource() ) then
    -- for each player already in the server
    for i, player in ipairs getElementsByType ( "player" ) do -- you forgot the "ipairs" part.
    -- binds the "i"-key to our function "modeIO"
    bindKey ( player, "i", "down", "modeIO" )
    end
    end
    end
    addEventHandler ( "onResourceStart", getRootElement(), Script_onResourceLoad )
    

  13. How to make the nametag larger and Bold and in another font. I have seen it on the most scripted server on MTA.

    I thikn you have to hide the normal nametags and create new ones with the directx draw functions.

  14. for example:
    yourbutton=guiCreateButton(0,0,20,20,false)
     
    function processclick(button,state)
    if button=="left" and state=="up" then
    --do what you want
    end
    end
    addEventHandler("onClientGUIClick",yourbutton,processclick)
    

    watch https://wiki.multitheftauto.com/wiki/Cat ... _Tutorials ,

    and try find it in wiki before asking in forums to help

    You say that I don't use the Wiki? Then why I know that this event exist? magic? because I use the LUA editor.

    I don't see how to use the players fuctions on the wiki pages on this fuction.

    That's because you don't look for them.

    https://wiki.multitheftauto.com/wiki/Int ... _the_click

  15. No matter how much Kye whines about "idea stealing", I find it easier in the long run (for a variety of purposes) to use player IDs.

    If you make a resource that assigns each player an ID when they join, you can substantially simplify the use of commands in your server.

    I second that, here's my ID script if you want to use it:

    http://jum.pastebin.com/d380519fc

    Woovie also posted his, but I'm not sure if you're allowed to use it, but since it's pretty much public I guess you could :P

  16. This is my player matching script, I suppose you could optimize it a bit :P

    You also need to modify it to work they way you want it too, since mine is actually part of an ID system, either way, here ya go :P

    function getNameMatches ( player_name )
    i = 1
    local matchingPlayers = { }
    if ( player_name ) then
    for k, player in ipairs ( getElementsByType ( "player" ) ) do
    local player_n = getPlayerName ( player )
    local match = string.find ( string.lower( player_n ), string.lower ( player_name ), 1, true ) -- I just added the true part since driver2 mentioned it, so I dont know if I put it correctly O_o
    if ( match ) then
    table.insert ( matchingPlayers, i, player )
    			i = i + 1
    end
    end
    if ( #matchingPlayers == 1 ) then
    return true, matchingPlayers[1] 
    elseif ( #matchingPlayers > 1 ) then
    return true, matchingPlayers
    else
    return false, "None"
    end	
    else
    return false, "Please enter a player name"
    end	
    end		
     
    function getPlayerFromPartialName ( source, player_name, script )
    if ( player_name ) then
    local sucess, value = getNameMatches ( player_name )
    if ( sucess ) then
    local matches = #value
    if ( matches == 1 ) then
    if ( script ) then return value[1] else 
    local player_nick = getPlayerName ( value[1] )
    local player_id = getElementData ( value[1], "ID" )
    outputChatBox ( "(" .. player_id .. ") " .. player_nick, source, 255, 255, 0 )
    end	
    else	
    outputChatBox ( "Players matching your search are: ", source, 255, 255, 0 )
    for k, player in ipairs ( value ) do
    local player_nick = getPlayerName ( value[k] )
    local player_id = getElementData ( value[k], "ID" )
    outputChatBox ( "(" .. player_id .. ") " .. player_nick, source, 255, 255, 0 )
    end
    return true
    end		
    else
    outputChatBox ( value, source, 255, 0, 0 )
    end
    end
    end
    

×
×
  • Create New...