Jump to content

Script Problem with GUI[Help]!


Price.

Recommended Posts

Posted (edited)

well guys this code will seem a big mess but its a carjacker job when i hit the marker a gui should get opened and tells me accept or close if i accepted i get into criminal team and the job starts where i go steal a car and bring it back , the problem is it tells me go and steal the car marked on your map without any gui or getting me into criminal team

Server Sided:

vehicleslocations = { 
    {2376.79296875, -1928.578125, 13.3828125}, 
    {2494.0791015625, -1751.0302734375, 13.484757423401} 
} 
  
idlist = {602, 496, 589, 429, 541, 562, 559, 411, 560, 506}              
  
  
addEventHandler("onPlayerQuit", root, 
function() 
    if vehicle[source] then 
        destroyElement(vehicle[source]) 
        destroyElement(vehicleBlip[source]) 
        vehicle[source] = nil 
        vehicleBlip[source] = nil 
    end 
end) 
Teame = createTeam("Criminal", 255, 255, 0) 
  
  
  
CriminalTeams = { [Teame] = true } 
CrimVehs = { [420] = true } 
  
function teamSet ( ) 
    local team = getTeamFromName ( "Criminal" ) 
    if team then 
        setPlayerTeam ( source, team ) 
        setPlayerNametagColor ( source, 0, 255, 0 ) 
            setElementModel(source, 57) 
         
            outputChatBox("You are now employed as a Carjacker!", thePlayer) 
        else 
            local teamw = getTeamFromName ( "Criminal" ) 
            if teamw then 
            cancelEvent() 
            outputChatBox("You are already a Carjacker!", source) 
        end 
    end 
end 
addEvent ( "sTeame", true) 
addEventHandler ( "sTeame", root, teamSet ) 
  
  
function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle 
    if getElementType ( thePlayer ) == "player" then 
        if ( CriminalVehs[getElementModel ( source )] ) and ( not CriminalTeams[getPlayerTeam( thePlayer )] ) then -- if the vehicle is one of 4 police cars, and the skin is not a police skin 
            removePedFromVehicle( thePlayer )-- force the player out of the vehicle 
            outputChatBox("Only Carjackers can drive this vehicle!", thePlayer) 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 
  
  
  
markers = { } 
blips = { } 
peds = { } 
mposi = { } 
mposii = {} 
  

Client Sided:

GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
} 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(0.29, 0.24, 0.42, 0.49, "", true) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1], false) 
  
        bAccept = guiCreateMemo(0.08, 0.20, 0.41, 0.67, "", true, GUIEditor.window[1]) 
         
        bAccept = guiCreateButton(0.60, 0.20, 0.34, 0.17, "Accept", true, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "sa-header") 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") 
        addEventHandler("onClientGUIClick", bAccept, showGUIbf, false) 
        addEventHandler("onClientGUIClick", bAccept, joinTeam, false) 
         
        bClose = guiCreateButton(0.67, 0.61, 0.20, 0.16, "CLOSE", true, GUIEditor.window[1]) 
        guiSetProperty(bClose, "NormalTextColour", "FFAAAAAA")  
        addEventHandler("onClientGUIClick", bClose, showGUIbf, false) 
         
        GUIEditor.memo[1] = guiCreateMemo(0.08, 0.20, 0.41, 0.67, "Become a Carjacker and Steal the cars marked on your map and get it here to get your money", true, GUIEditor.window[1]) 
         
    end 
) 
  
   CarJackerPed = createPed(250, 2744.6552734375, -2004.0751953125, 13.547199249268) 
createBlipAttachedTo(CarJackerPed,12, 2, 255, 0, 0, 255, 0, 200) 
setPedRotation(CarJackerPed, 358) 
setElementFrozen(CarJackerPed, true)     
  
pedMarker = createMarker(2744.5107421875, -2002.25390625, 12.5, "cylinder", 1.5, 255, 0, 255, 255) 
vehicleMarker = createMarker(2758.03101, -2000.57129, 12.5, "cylinder", 1.5, 0, 255, 0, 255) 
  
function showGUIbt(hitElement) 
 if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
 guiSetVisible(GUIEditor.window[1], true) 
 showCursor( true ) 
 end 
 end 
  
function showGUIbf() 
    guiSetVisible (GUIEditor.window[1], false ) 
    showCursor ( false ) 
end 
 addEventHandler("onClientMarkerHit", pedMarker, showGUIbt)  
  
  
function joinTeam() 
    triggerServerEvent("sTeame", localPlayer, "teamSet") 
end 
  
  
  
local vehicle = {} 
local vehicleBlip = {} 
  
addEventHandler("onMarkerHit", root, 
function(player) 
    if getElementType(player) == "player" then 
        if source == pedMarker then 
            if not vehicle[player] then 
                local ID = idlist[math.random(#idlist)] 
                local x, y, z = unpack(vehicleslocations[math.random(#vehicleslocations)]) 
                vehicle[player] = createVehicle(ID, x, y, z) 
                vehicleBlip[player] = createBlipAttachedTo(vehicle[player], 32) 
                setElementVisibleTo(vehicleBlip[player], root, false) 
                for i, p in ipairs(getElementsByType("player")) do 
                    if getPlayerTeam(player) == getTeamFromName("Criminal") then 
                        setElementVisibleTo(vehicleBlip[player], p, true) 
                    end 
                end 
                outputChatBox("Go and steal the car marked on your map and bring it here", player, 170, 0, 0) 
            else 
                outputChatBox("You already got a car to steal", player, 170, 0, 0) 
            end 
        elseif source == vehicleMarker then 
            if vehicle[player] then 
                local veh = getPedOccupiedVehicle(player) 
                if veh then 
                    local contoler = getVehicleController(veh) 
                    if contoler == player then 
                        destroyElement(vehicle[player]) 
                        destroyElement(vehicleBlip[player]) 
                        vehicle[player] = nil 
                        vehicleBlip[player] = nil 
                        givePlayerMoney(player, math.random(1000, 1500)) 
                    end 
                end 
            end 
        end 
    end 
end) 

Edited by Guest

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

Posted

What you put as client side also includes server side functions, which means it'll never work.

Also, if you create a vehicle client sided, then you won't be able to use it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, you can do that, but your script is wrong.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

well uhm iam really confused , can you help ?

uhm which arguments to use in client and server sided?

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

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