Jump to content

Small GUI Problem


Recommended Posts

Hi i have a problem with this gui it will be shown on all players!

Server:

function oncolehit (player) 
    pname = getPlayerName (player) 
        if getElementType ( player ) == "player" then 
        veh = getPedOccupiedVehicle (player) 
        seat = getPedOccupiedVehicleSeat (player) 
            if (veh) and (seat == 0) then 
            local result = mysql_query( handler2, "SELECT * FROM accounts WHERE Name = '"..pname.."'" ) 
            local row = mysql_fetch_assoc(result) 
                if row then 
                if (row["Wert"] == "1") then 
    outputChatBox ("Danke das du das Parkhaus besuchst!", player, 0,255,0) 
    eschrankefunc () 
    end 
    mysql_free_result(result) 
else 
    if getElementType ( player ) == "player" then 
            veh = getPedOccupiedVehicle (player) 
        seat = getPedOccupiedVehicleSeat (player) 
            if (veh) and (seat == 0) then 
            triggerClientEvent (player, "openGUI", player) 
                    end 
                end 
            end 
        end 
end 
end 
addEventHandler ("onColShapeHit", cole, oncolehit) 

client:

function showwindow () 
    local isshowed = guiGetVisible (Grundflaeche) 
    if (isshowed == true) then 
        guiSetVisible (Grundflaeche, false) 
        showCursor(false) 
        guiSetInputEnabled(false) 
end 
    if (isshowed == false) then 
        guiSetVisible (Grundflaeche, true) 
        showCursor(true) 
        guiSetInputEnabled(true) 
    end 
    end 
addEvent ("openGUI", true) 
addEventHandler ("openGUI", getRootElement(), showwindow) 

Sorry for my bad english!

Please help me :P

Link to comment

Server:

function oncolehit (p, hitElement) 
    pname = getPlayerName (p) 
        if ( getElementType ( p ) == "player" ) then 
        veh = getPedOccupiedVehicle (p) 
        seat = getPedOccupiedVehicleSeat (p) 
            if (veh) and (seat == 0) then 
            local result = mysql_query( handler2, "SELECT * FROM accounts WHERE Name = '"..pname.."'" ) 
            local row = mysql_fetch_assoc(result) 
                if row then 
                if (row["Wert"] == "1") then 
    outputChatBox ("Danke das du das Parkhaus besuchst!", p, 0,255,0) 
    eschrankefunc () 
    end 
    mysql_free_result(result) 
else 
    if ( getElementType ( p ) == "player" ) then 
            veh = getPedOccupiedVehicle (p) 
        seat = getPedOccupiedVehicleSeat (p) 
            if (veh) and (seat == 0) then 
            triggerClientEvent (hitElement, "openGUI", hitElement) 
                    end 
                end 
            end 
        end 
end 
end 
addEventHandler ("onColShapeHit", cole, oncolehit) 

try this

Edited by Guest
Link to comment

mybe this

client :

function showwindow () 
        guiSetVisible( Grundflaeche, not guiGetVisible( Grundflaeche ) ) 
        showCursor( guiGetVisible( Grundflaeche ) ) 
        guiSetInputEnabled( guiGetVisible( Grundflaeche ) ) 
end 
addEvent ( "openGUI", true ) 
addEventHandler ( "openGUI", localPlayer, showwindow ) 

server:

function oncolehit ( hitElement, matchingDimension ) 
    if ( getElementType ( hitElement ) == "player" ) and ( getPedOccupiedVehicle ( hitElement ) ) and ( getPedOccupiedVehicleSeat ( hitElement ) == 0 ) and matchingDimension then 
        local result = mysql_query( handler2, "SELECT * FROM accounts WHERE Name = '" .. getPlayerName ( hitElement ) .. "'" ) 
        local row = mysql_fetch_assoc( result ) 
        if ( row ) and ( row["Wert"] == "1" ) then 
            outputChatBox ( "Danke das du das Parkhaus besuchst!", hitElement, 0, 255, 0 ) 
            eschrankefunc () 
        end 
        mysql_free_result( result ) 
        triggerClientEvent ( hitElement, "openGUI", hitElement ) 
    end 
end 
addEventHandler ( "onColShapeHit", cole, oncolehit ) 

Link to comment

Your problem is that the GUI is showing for everyone, not only for who has hit the col?

Well, the trigger is only for who hit the col, so the problem is no problem. :mrgreen:

Maybe you want post the rest of the code?

Where is the function eschrankefunc () ?

Maybe you have other script trigger the event openGUI for everyone? try to change it to something else.

Link to comment

Here is the function:

function eschrankefunc () 
if (eschrankeMovingState == false) then 
    if (eschranke == false) then 
        eschrankeMovingState = true 
        setTimer(setefalse, 1500, 1) 
        moveObject (schrankee, 1500, -1804.5000000,1293.0097700,15.8000000, 0, -90, 0) 
        eschranke = true 
        setTimer (eschrankefunc, 2000, 1) 
    else 
        eschrankeMovingState = true 
        setTimer(setefalse, 1500, 1) 
        moveObject (schrankee, 1500, -1804.5000000,1293.0097700,15.8000000, 0, 90, 0) 
        eschranke = false 
end 
end 
end 
  
function setefalse () 
eschrankeMovingState = false 
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...