Jump to content

Race gamemode force into spectate mode if not logged in


koeno100

Recommended Posts

  • MTA Team

I only tested the code alone on my server.

This is an ugly hack and I don't recommend it.

It probably won't put the player into spectator mode (requires more changes).

File: race_server.lua

Search the line

addEventHandler('onPlayerQuit', g_Root 

and move the anonymous function out and give it a name.

function handlePlayerQuit() 
    destroyBlipsAttachedTo(source) 
    table.removevalue(g_Players, source) 
    -- ... 
end 

Don't forget to add the handler in onPlayerQuit and add a new event onPlayerLogout for it.

addEventHandler('onPlayerQuit', g_Root, handlePlayerQuit) 
addEventHandler('onPlayerLogout', g_Root, handlePlayerQuit) 

Search for

addEventHandler('onPlayerJoin', g_Root, joinHandlerByEvent) 

and add below that line:

addEventHandler('onPlayerLogin', g_Root, joinHandlerByEvent) 

Search for

function joinHandlerByEvent() 

and extend the function:

function joinHandlerByEvent() 
    if getAccountName(getPlayerAccount(source)) == 'guest' then 
        return 
    end 
    setPlayerNotReady(source) 
    joinHandlerBoth() 
end 

Search for

if not table.find(g_Players, p) then 

and extend the code block:

if not table.find(g_Players, p) then 
                if getAccountName(getPlayerAccount(p)) ~= 'guest' then 
                    player = p 
                    break 
                end 
            end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...