Jump to content

Other player can acess other player checkpoint


kuwalda

Recommended Posts

Okey, here is my code for simple racing system, but why do other players are allowed to use other players checkpoints.

playerMarkerTable = { } 
  
function testejam(thePlayer, command) 
    if ( getElementData( thePlayer, "allowrace"  ) == 1 ) then 
                if ( getElementData ( thePlayer, "dbid" ) == 2 ) then 
                    setElementData(thePlayer, "laiks", getTickCount ()) 
                end 
            local ciga = getElementData ( thePlayer, "dbid" ) 
            outputChatBox("Tavs ID:"..tonumber(ciga)..".", thePlayer, 255, 255, 0) 
            destroyElement(playerMarkerTable[thePlayer]) 
            playerMarkerTable[thePlayer] = createMarker(blueBerryRally[ciga][1], blueBerryRally[ciga][2], blueBerryRally[ciga][3], "checkpoint", 6, 190, 156, 252, 170) 
            setElementVisibleTo(playerMarkerTable[thePlayer], root, false) 
            setElementVisibleTo(playerMarkerTable[thePlayer], thePlayer, true) 
            if ( #blueBerryRally == ciga ) then 
                outputChatBox("Finish:"..(getTickCount () - getElementData( thePlayer, "laiks" )) / 1000 .."sec. GL NEXT TIME", root, 255, 255, 0) 
                setElementData(thePlayer, "dbid", 1) 
                destroyElement(playerMarkerTable[thePlayer]) 
            end  
            setElementData ( thePlayer, "dbid", getElementData ( thePlayer, "dbid" ) + 1 ) 
        if isElementVisibleTo(playerMarkerTable[thePlayer],thePlayer) then 
            addEventHandler( "onMarkerHit", playerMarkerTable[thePlayer], testejam ) 
        end 
    end 
end 
addCommandHandler("race", testejam) 

I belive problem is in if isElementVisibleTo(playerMarkerTable[thePlayer],thePlayer) then ,but how is it possible for that player to see that element? Please help, I have no idea what is wrong here.

Link to comment

You are purposely setting the marker to be visible to that specific player ( thePlayer ).

setElementVisibleTo(playerMarkerTable[thePlayer], root, false) --Set marker invisible to all. 
setElementVisibleTo(playerMarkerTable[thePlayer], thePlayer, true) -- Set marker visible to thePlayer. 

What are you trying to do here? I've already replied in your other topic, also.

If you want only the player who typed the command to be able to interact with that marker then check at the beginning if source( which is the marker hit ) is in fact playerMarkerTable[thePlayer] ( which should be the player's marker ). But it should already be visible to that one player only.

Link to comment

Thanks for you time and effort helping me, but to be more clearer about my problem:

when player is driving this race and other player types /race afterwards, first players checkpoints are being "stolen" and does not appear anymore, also second player are able to use those checkpoints, which were defined for first player.

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...