Jump to content

[HELP][WIP] Train driver job


Recommended Posts

Hello, I am trying to make a trian driver job, I have made the window, but I will need some help, I don't want no body to do it I just need some help.

Window:

GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
    radiobutton = {}, 
    tab = {}, 
    label = {}, 
    tabpanel = {}, 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(684, 215, 491, 334, "CFR - Sofer De Tren", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 0.75) 
  
        GUIEditor.button[1] = guiCreateButton(52, 169, 136, 65, "Angajeaza-te", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "default-bold-small") 
        GUIEditor.button[2] = guiCreateButton(299, 169, 136, 65, "Demisioneaza", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[2], "default-bold-small") 
        GUIEditor.button[3] = guiCreateButton(299, 259, 136, 65, "Închide", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[3], "default-bold-small") 
        GUIEditor.memo[1] = guiCreateMemo(206, 180, 76, 85, "", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(252, 119, 70, 54, "", false, GUIEditor.window[1]) 
        GUIEditor.memo[2] = guiCreateMemo(46, 35, 393, 124, "                              Bun venit la gara CFR!\nCautamt conductori de locomotiva, tot ce trebuie sa faci este sa conduci trenul si sa iei pasageri. Ia o colomotiva, o poti gasii pe sine, si incepeti slujba.\n\n                                                   Mult Succes!", false, GUIEditor.window[1]) 
        guiMemoSetReadOnly(GUIEditor.memo[2], true) 
  
        GUIEditor.tabpanel[1] = guiCreateTabPanel(178, 196, 60, 57, false, GUIEditor.memo[2]) 
  
        GUIEditor.tab[1] = guiCreateTab("Tab", GUIEditor.tabpanel[1]) 
  
  
        GUIEditor.radiobutton[1] = guiCreateRadioButton(191, 271, 75, 44, "", false, GUIEditor.window[1]) 
        guiRadioButtonSetSelected(GUIEditor.radiobutton[1], true)     
    end 
) 
  
  

Now, first of all, I want to make it so when a player hits a marker the window pops up, I will try some functions from the wiki, but if you want to help me, thats fine.

--------------------------EDITED!--------------------------

I have used this code for the server side.

  
jobMarker = createMarker (1942.57, 2184.79, 9.82, "cylinder", 1, 255, 0, 0, 127) 
  
addEvent ("viewGUI", true) 
function markerHit (hitPlayer, matchingDimension) 
  if (source == jobMarker) then 
    triggerClientEvent ("viewGUI", hitPlayer) 
    outputChatBox ("Bun venit la gara Romana CFR.", hitPlayer, 255, 0, 0) 
  end 
end 
addEventHandler ("onMarkerHit", getRootElement(), markerHit) 
  
addEventHandler ("onClientResourceStart", getRootElement(), resourceStart) 
  
function menuShow () 
    visableornot = guiGetVisible (theWindow) 
    if (visableornot == true) then 
        guiSetVisible (theWindow, false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (theWindow, true) 
        showCursor (true) 
    end 
end 

I want to know if I need to add some more to it.

Edited by Guest
Link to comment

Server:

jobMarker = createMarker (-1973.02600, 117.74309, 27.68750, "cylinder", 1, 255, 0, 0, 127) 
  
addEvent ("viewGUI", true) 
function markerHit (hitPlayer, matchingDimension) 
  if (source == jobMarker) then 
    triggerClientEvent ("viewGUI", hitPlayer) 
    outputChatBox ("Bun venit la gara Romana CFR.", hitPlayer, 255, 255, 0) 
  end 
end 
addEventHandler ("onMarkerHit", getRootElement(), markerHit) 

Client:

GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
    tab = {}, 
    label = {}, 
    tabpanel = {}, 
} 
  
    function() 
        theWindow = guiCreateWindow(684, 215, 491, 334, "CFR - Sofer De Tren", false) 
        guiWindowSetSizable(theWindow, false) 
        guiSetAlpha(theWindow, 0.75) 
        GUIEditor.button[1] = guiCreateButton(52, 169, 136, 65, "Angajeaza-te", false, theWindow) 
        guiSetFont(GUIEditor.button[1], "default-bold-small") 
        GUIEditor.button[2] = guiCreateButton(299, 169, 136, 65, "Demisioneaza", false, theWindow) 
        guiSetFont(GUIEditor.button[2], "default-bold-small") 
        GUIEditor.button[3] = guiCreateButton(299, 259, 136, 65, "Închide", false, theWindow) 
        guiSetFont(GUIEditor.button[3], "default-bold-small") 
        GUIEditor.label[1] = guiCreateLabel(252, 119, 70, 54, "", false, theWindow) 
        GUIEditor.memo[2] = guiCreateMemo(46, 35, 393, 124, "                              Bun venit la gara CFR!\nCautam conductori de locomotiva, tot ce trebuie sa faci este sa conduci trenul si sa iei pasageri. Ia o colomotiva, o poti gasii pe sine, si incepeti slujba.\n\n                                                   Mult Succes!", false, GUIEditor.window[1]) 
  
        GUIEditor.tabpanel[1] = guiCreateTabPanel(178, 196, 60, 57, false, GUIEditor.memo[2]) 
  
        GUIEditor.tab[1] = guiCreateTab("Tab", GUIEditor.tabpanel[1])     
end 
addEventHandler ("onClientResourceStart", getRootElement(), resourceStart) 
  
function menuShow () 
    visableornot = guiGetVisible (theWindow) 
    if (visableornot == true) then 
        guiSetVisible (theWindow, false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (theWindow, true) 
        showCursor (true) 
    end 
end 

When I hit the marker, just the outputChatBox message shows, but the window doesn't... Whats wrong?

Link to comment

Maybe like this will be easy? client side :

local marker = createMarker ( x,y,z, "cylinder", size,r,g,b, 170 ) 
  
addEventHandler ( "onClientMarkerHit", marker, 
    function ( player ) 
        if ( player == localPlayer )  then 
            guiSetVisible ( window, true ) 
            showCursor ( true ) 
        end 
    end 
) 

Replace :

x,y,z = You're Position To Create The Marker

Window = You're Window

Just That Have Fun

Any Thing Just Ask

Mr.Pres[T]ege

.......

Link to comment

Try this code

--Server Side

jobMarker = createMarker (1942.57, 2184.79, 9.82, "cylinder", 1, 255, 0, 0, 127) 
  
function markerHit (hitPlayer, matchingDimension) 
  if (source == jobMarker) then 
    triggerClientEvent ("viewGUI", hitPlayer) 
    outputChatBox ("Bun venit la gara Romana CFR.", hitPlayer, 255, 0, 0) 
  end 
end 
addEventHandler ("onMarkerHit", getRootElement(), markerHit)) 

--Client Side

GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
    radiobutton = {}, 
    tab = {}, 
    label = {}, 
    tabpanel = {}, 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(684, 215, 491, 334, "CFR - Sofer De Tren", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 0.75) 
  
        GUIEditor.button[1] = guiCreateButton(52, 169, 136, 65, "Angajeaza-te", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "default-bold-small") 
        GUIEditor.button[2] = guiCreateButton(299, 169, 136, 65, "Demisioneaza", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[2], "default-bold-small") 
        GUIEditor.button[3] = guiCreateButton(299, 259, 136, 65, "Închide", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[3], "default-bold-small") 
        GUIEditor.memo[1] = guiCreateMemo(206, 180, 76, 85, "", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(252, 119, 70, 54, "", false, GUIEditor.window[1]) 
        GUIEditor.memo[2] = guiCreateMemo(46, 35, 393, 124, "                              Bun venit la gara CFR!\nCautamt conductori de locomotiva, tot ce trebuie sa faci este sa conduci trenul si sa iei pasageri. Ia o colomotiva, o poti gasii pe sine, si incepeti slujba.\n\n                                                   Mult Succes!", false, GUIEditor.window[1]) 
        guiMemoSetReadOnly(GUIEditor.memo[2], true) 
  
        GUIEditor.tabpanel[1] = guiCreateTabPanel(178, 196, 60, 57, false, GUIEditor.memo[2]) 
  
        GUIEditor.tab[1] = guiCreateTab("Tab", GUIEditor.tabpanel[1]) 
  
  
        GUIEditor.radiobutton[1] = guiCreateRadioButton(191, 271, 75, 44, "", false, GUIEditor.window[1]) 
        guiRadioButtonSetSelected(GUIEditor.radiobutton[1], true)     
    end 
) 
  
function menuShow () 
    visableornot = guiGetVisible (GUIEditor.window[1]) 
    if (visableornot == true) then 
        guiSetVisible (GUIEditor.window[1], false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (GUIEditor.window[1], true) 
        showCursor (true) 
    end 
end 
addEvent ("viewGUI", true) 
addEventHandler( "viewGUI" , root, menuShow) 

Link to comment

Client :

GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
    radiobutton = {}, 
    tab = {}, 
    label = {}, 
    tabpanel = {}, 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(684, 215, 491, 334, "CFR - Sofer De Tren", false) 
            guiSetVisible ( GUIEditor.window[1], false ) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 0.75) 
  
        GUIEditor.button[1] = guiCreateButton(52, 169, 136, 65, "Angajeaza-te", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "default-bold-small") 
        GUIEditor.button[2] = guiCreateButton(299, 169, 136, 65, "Demisioneaza", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[2], "default-bold-small") 
        GUIEditor.button[3] = guiCreateButton(299, 259, 136, 65, "Închide", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[3], "default-bold-small") 
        GUIEditor.memo[1] = guiCreateMemo(206, 180, 76, 85, "", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(252, 119, 70, 54, "", false, GUIEditor.window[1]) 
        GUIEditor.memo[2] = guiCreateMemo(46, 35, 393, 124, "                              Bun venit la gara CFR!\nCautamt conductori de locomotiva, tot ce trebuie sa faci este sa conduci trenul si sa iei pasageri. Ia o colomotiva, o poti gasii pe sine, si incepeti slujba.\n\n                                                   Mult Succes!", false, GUIEditor.window[1]) 
        guiMemoSetReadOnly(GUIEditor.memo[2], true) 
  
        GUIEditor.tabpanel[1] = guiCreateTabPanel(178, 196, 60, 57, false, GUIEditor.memo[2]) 
  
        GUIEditor.tab[1] = guiCreateTab("Tab", GUIEditor.tabpanel[1]) 
  
  
        GUIEditor.radiobutton[1] = guiCreateRadioButton(191, 271, 75, 44, "", false, GUIEditor.window[1]) 
        guiRadioButtonSetSelected(GUIEditor.radiobutton[1], true)     
    end 
) 
  
addEvent ("viewGUI", true) 
addEventHandler( "viewGUI" , root, 
function  () 
            guiSetVisible ( GUIEditor.window[1], true ) 
            showCursor ( true ) 
    end 
) 

Server :

local jobMarker = createMarker (1942.57, 2184.79, 9.82, "cylinder", 1, 255, 0, 0, 127) 
  
addEventHandler ("onMarkerHit", jobMarker, 
function  (hitPlayer) 
  if (getElementType(hitPlayer) == "player") then 
    triggerClientEvent ("viewGUI",source) 
    outputChatBox ("Bun venit la gara Romana CFR.", hitPlayer, 255, 0, 0) 
  end 
end 
) 

Try it.

Link to comment

It worked, thanks, now, how do I do this button

GUIEditor.button[3] = guiCreateButton(299, 259, 136, 65, "Închide", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[3], "default-bold-small") 

A closing window button?

PS: Just tell me what to do, I want to do the code by myself.

Link to comment

Hm.. it doesn't work..

GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
    tab = {}, 
    label = {}, 
    tabpanel = {}, 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(684, 215, 491, 334, "CFR - Sofer De Tren", false) 
            guiSetVisible ( GUIEditor.window[1], false ) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 0.75) 
  
        GUIEditor.button[1] = guiCreateButton(52, 169, 136, 65, "Angajeaza-te", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "default-bold-small") 
        GUIEditor.button[2] = guiCreateButton(299, 169, 136, 65, "Demisioneaza", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[2], "default-bold-small") 
        GUIEditor.button[3] = guiCreateButton(299, 259, 136, 65, "Închide", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[3], "default-bold-small") 
        GUIEditor.label[1] = guiCreateLabel(252, 119, 70, 54, "", false, GUIEditor.window[1]) 
        GUIEditor.memo[2] = guiCreateMemo(46, 35, 393, 124, "                              Bun venit la gara CFR!\nCautamt conductori de locomotiva, tot ce trebuie sa faci este sa conduci trenul si sa iei pasageri. Ia o colomotiva, o poti gasii pe sine, si incepeti slujba.\n\n                                                   Mult Succes!", false, GUIEditor.window[1]) 
        guiMemoSetReadOnly(GUIEditor.memo[2], true) 
  
        GUIEditor.tabpanel[1] = guiCreateTabPanel(178, 196, 60, 57, false, GUIEditor.memo[2]) 
  
        GUIEditor.tab[1] = guiCreateTab("Tab", GUIEditor.tabpanel[1])     
    end 
) 
  
addEvent ("viewGUI", true) 
addEventHandler( "viewGUI" , root, 
function  () 
            guiSetVisible ( GUIEditor.window[1], true ) 
            showCursor ( true ) 
    end 
) 
  
addEventHandler("onClientGUIClick", GUIEditor.button[3], 
function() 
guiSetVisible(GUIEditor.window[1], false) 
showCursor(false) 
end 
) 

Is the code right?

Link to comment
Try this
addEventHandler("onClientGUIClick", root, 
function() 
if ( source == GUIEditor.button[3] ) then 
guiSetVisible(GUIEditor.window[1], false) 
showCursor(false) 
end 
end 
) 

And this code works, thanks.

-------

Now, I want to create a team, when a player clicks it, it shoud say, ''You are now an employed at the train station'' and the player should get a skin (I will decide what skin) and he also needs to be put in the specified team. Maybe a train should spawn on the rail.

GUIEditor.button[1] = guiCreateButton(52, 169, 136, 65, "Angajeaza-te", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "default-bold-small") 

And this is the button. Just give me an idea of how to make it, don't give me the whole function, I want to try on my own.

Link to comment

-- Client --

addEventHandler("onClientGUIClick",GUIEditor.button[1],  
function ()  
triggerServerEvent("onAskToSetTeamAndSkin",localPlayer); 
       end 
); 

-- Server --

  
local team = createTeam ( "TEAM NAME",r,g,b ); 
  
  
addEvent("onAskToSetTeamAndSkin",true); 
addEventHandler("onAskToSetTeamAndSkin",root, function () 
spawnPlayer(source,x,y,z,0,SKIN,0,0,team); 
        end 
); 

Replace :

r,g,b = teamColor

x,y,z = you're position to spawn player on it

SKIN = Skin Id

and the spawnPlayer Funtion will setPlayerTeam On The Team

Try it .

:wink:

Link to comment
-- Client --

addEventHandler("onClientGUIClick",GUIEditor.button[1],  
function ()  
triggerServerEvent("onAskToSetTeamAndSkin",localPlayer); 
       end 
); 

-- Server --

  
local team = createTeam ( "TEAM NAME",r,g,b ); 
  
  
addEvent("onAskToSetTeamAndSkin",true); 
addEventHandler("onAskToSetTeamAndSkin",root, function () 
spawnPlayer(source,x,y,z,0,SKIN,0,0,team); 
        end 
); 

Replace :

r,g,b = teamColor

x,y,z = you're position to spawn player on it

SKIN = Skin Id

and the spawnPlayer Funtion will setPlayerTeam On The Team

Try it .

:wink:

Just give me an idea of how to make it, don't give me the whole function, I want to try on my own.
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...