Alen141 Posted August 14, 2013 Share Posted August 14, 2013 Hey guys, I've been working on some simple job script lately but as I don't get xml nodes and stuff too much I can't make it easier for me to create jobs, if I would want to make another job I would have to do the same procedure again and again.. So what I wanted in my xml : <job name = ""(this would be elemnt data that would set "Job") position=""(position of marker) weapons=""(weapon ids ) skin=""(skin he would get) description=""(i guess it's self explanatory) My Police Job scripts : client side : jobWnd = guiCreateWindow(422, 250, 511, 272, "Job GUI v0.1", false) guiWindowSetSizable(jobWnd, false) desc = guiCreateMemo(9, 20, 492, 117, "Description: ....", false, jobWnd) guiMemoSetReadOnly(desc, true) yesbtn = guiCreateButton(64, 215, 156, 47, "Take Job", false, jobWnd) nobtn = guiCreateButton(266, 215, 156, 47, "Cancel", false, jobWnd) quitbtn = guiCreateButton(168, 147, 156, 47, "Quit Job", false, jobWnd) guiSetVisible(jobWnd, false) local jobmarker = createMarker ( 1536.4000244141, -1662.8000488281, 12.5, "cylinder", 1.5, 100, 149, 237, 170 ) function SAPDjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(jobWnd) then guiSetVisible(jobWnd, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", jobmarker, SAPDjob) function closeGUI() if (source == nobtn) then showCursor(false) guiSetVisible( jobWnd, false ) end end addEventHandler("onClientGUIClick",root,closeGUI) function takeJob() if ( source == yesbtn ) then triggerServerEvent("getJob", getLocalPlayer()) guiSetVisible(jobWnd,false) showCursor(false) end end addEventHandler("onClientGUIClick",root,takeJob) function quitJob() if ( source == quitbtn ) then triggerServerEvent("quitJob", getLocalPlayer()) guiSetVisible(jobWnd,false) showCursor(false) end end addEventHandler("onClientGUIClick",root,quitJob) server side : exports.Scoreboard:scoreboardAddColumn( "Job" ) function createCivTeam () Polteam = createTeam ("Police", 100, 149, 237) noTeam = createTeam ("Unemployed", 253, 208, 23) end addEventHandler ("onResourceStart", resourceRoot, createCivTeam) function joinTeam() local playerTeam = getPlayerTeam ( source ) if not playerTeam or playerTeam == noTeam then setPlayerTeam(source,Polteam) setPlayerNametagColor ( source, 100, 149, 237) setElementModel(source, 280) giveWeapon ( source, 3 ) giveWeapon ( source, 23, 200 ) giveWeapon ( source, 26, 200 ) setElementData ( source, "Job", "Officer" ) outputChatBox("#00FF00You are now employed as Police Officer!", getRootElement(), 255, 0, 0, true ) else outputChatBox ( "#FF0000You are already employed, quit your job first!", getRootElement(), 255, 0, 0, true ) end end addEvent("getJob", true) addEventHandler("getJob",root,joinTeam) function quitTeam() local playerTeam = getPlayerTeam ( source ) if (playerTeam == Polteam) then setPlayerTeam(source, noTeam) setPlayerNametagColor ( source, 253, 208, 23 ) setElementModel(source, 0) setElementData ( source, "Job", "Unemployed" ) takeAllWeapons ( source ) outputChatBox("#00FF00You are now Unemployed and all of your weapons were \"taken\"", getRootElement(), 255, 0, 0, true ) else outputChatBox("#FF0000You don't have this job so you can't quit!", getRootElement(), 255, 0, 0, true ) end end addEvent("quitJob", true) addEventHandler("quitJob",root,quitTeam) How to make shorter procedure of creating jobs ? Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 I've been thinking about an easier system too. I was thinking about creating a function that create's a gui with specified information (given as a parameter) over and over again. You can customise this as much as you want. Then create a small script for easy jobs like, hit a marker to start and a marker to finish. The rest of the extra function's like; jail, arrest, tow vehicle, repair vehicle etc you've to create other functions. but the standart functions you can create and reuse over and over again. We all hit a marker or talk to a npc to start the job. We all get a team or data that's being set, the data is being saved at all the jobs. Dont write that 1000 times, write it once with parameters! Link to comment
Alen141 Posted August 14, 2013 Author Share Posted August 14, 2013 I've been thinking about an easier system too. I was thinking about creating a function that create's a gui with specified information (given as a parameter) over and over again. You can customise this as much as you want.Then create a small script for easy jobs like, hit a marker to start and a marker to finish. The rest of the extra function's like; jail, arrest, tow vehicle, repair vehicle etc you've to create other functions. but the standart functions you can create and reuse over and over again. We all hit a marker or talk to a npc to start the job. We all get a team or data that's being set, the data is being saved at all the jobs. Dont write that 1000 times, write it once with parameters! you got my point, I've got this idea when checking XML in my spawn menu script Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 Why do you want to save it into a XML file? Link to comment
Alen141 Posted August 14, 2013 Author Share Posted August 14, 2013 Why do you want to save it into a XML file? not save it, but "make it" in XML, it makes things alot easier, after making code that allows you to create it in XML you can use alot simpler codes inside XML files as I mentioned before : "Police" position="x,y,z" skin="255" weapon(s)="31" Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 Sec, working on something to show you! Link to comment
Alen141 Posted August 14, 2013 Author Share Posted August 14, 2013 Sec, working on something to show you! ok, thx man Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 (edited) What do you think about this; function createJob( jobName, jobDesc, jobTeam, jobSkin, jobWeapon, jobMarkerX, jobMarkerY, jobMarkerZ, jobMarkerR, jobMarkerG, jobMarkerB, jobMarkerA ) marker = createMarker( jobMarkerX, jobMarkerY, jobMarkerZ, "cylinder", 2, jobMarkerR, jobMarkerG, jobMarkerB, jobMarkerA ); setElementData(marker, "job", jobName); createTeam( tostring(jobTeam), jobMarkerR, jobMarkerG, jobMarkerB ); local X = 0.375 local Y = 0.250 local Width = 1 local Height = 1 gui = {} gui["_jobWindow".. jobName] = guiCreateWindow (X, Y, Width/4, Height/4, tostring( jobName ), true) guiWindowSetSizable(gui["_jobWindow".. jobName], false) gui["_jobWindow".. jobName .."_lblDesc"] = guiCreateLabel ( 0.1, 0.1, 0.8, 0.1, jobDesc, true, gui["_jobWindow".. jobName]); gui["_jobWindow".. jobName .."_btnAccept"] = guiCreateButton( 0.1, 0.8, 0.8 , 0.2, "Take the job!", true, gui["_jobWindow".. jobName] ); guiSetVisible(gui["_jobWindow".. jobName], false); end addEventHandler("onClientMarkerHit", root, function ( hitElement ) local markerName = getElementData( source ); setGuiVisible( gui["_jobWindow".. markerName], true ); showCursor( true ); end ); didn't test it so it might contain bugs! Edited August 14, 2013 by Guest Link to comment
Alen141 Posted August 14, 2013 Author Share Posted August 14, 2013 What do you think about this; function createJob( thePlayer, jobName, jobDesc, jobTeam, jobSkin, jobWeapon, jobMarker, jobMarkerX, jobMarkerY, jobMarkerZ, jobMarkerR, jobMarkerG, jobMarkerB, jobMarkerA ) marker = createMarker( jobMarkerX, jobMarkerY, jobMarkerZ, "cylinder", 2, jobMarkerR, jobMarkerG, jobMarkerB, jobMarkerA ); setElementData(marker, "job", jobName); createTeam( tostring(jobTeam), jobMarkerR, jobMarkerG, jobMarkerB ); local X = 0.375 local Y = 0.250 local Width = 1 local Height = 1 gui = {} gui["_jobWindow".. jobName] = guiCreateWindow (X, Y, Width/4, Height/4, tostring( jobName ), true) guiWindowSetSizable(gui["_jobWindow".. jobName], false) gui["_jobWindow".. jobName .."_lblDesc"] = guiCreateLabel ( 0.1, 0.1, 0.8, 0.1, jobDesc, true, gui["_jobWindow".. jobName]); gui["_jobWindow".. jobName .."_btnAccept"] = guiCreateButton( 0.1, 0.8, 0.8 , 0.2, "Take the job!", true, gui["_jobWindow".. jobName] ); guiSetVisible(gui["_jobWindow".. jobName], false); end addEventHandler("onClientMarkerHit", root, function ( hitElement ) local markerName = getElementData( source ); setGuiVisible( gui["_jobWindow".. markerName], true ); showCursor( true ); end ); didn't test it so it might contain bugs! EDIT : idk if this will work, but maybe using theese, cause as I said not too good with xml nodes : xmlCreateFile xmlNodeSetAttribute Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 My script doesn't work with xml's. I hate xml files, blegh! hahaha, anyway all you have to do in the onClientResourceStart, is add a line; triggerEvent("createJob", localPlayer(), "Police", "Being a cop isn't easy ya know!", police, 280, 14, 0, 0, 5, 255, 0, 255, 255) Link to comment
Alen141 Posted August 14, 2013 Author Share Posted August 14, 2013 My script doesn't work with xml's. I hate xml files, blegh! hahaha, anyway all you have to do in the onClientResourceStart, is add a line; triggerEvent("createJob", localPlayer(), "Police", "Being a cop isn't easy ya know!", police, 280, 14, 0, 0, 5, 255, 0, 255, 255) ok Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 You also have to edit the gui of course. Its just a simple window with a label. Change the label to a memo, change the buttons so it has 2 buttons; accept and cancel. Add a nice picture, idk. Make it like you want it. Link to comment
Alen141 Posted August 14, 2013 Author Share Posted August 14, 2013 You also have to edit the gui of course. Its just a simple window with a label. Change the label to a memo, change the buttons so it has 2 buttons; accept and cancel. Add a nice picture, idk. Make it like you want it. I'll make sure I do it Link to comment
Castillo Posted August 14, 2013 Share Posted August 14, 2013 That script won't work, you used createTeam which is a server side only function. Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 That script won't work, you used createTeam which is a server side only function. Hmm I totally forgot that. Well a triggerClientFunction will do it. Beside that, its easier to do some things server sided anyway. Will add it as soon as I wake up! Link to comment
Castillo Posted August 14, 2013 Share Posted August 14, 2013 You mean triggerServerEvent, since triggerClientEvent is used on the server side to trigger events from the client side. Link to comment
tosfera Posted August 15, 2013 Share Posted August 15, 2013 You mean triggerServerEvent, since triggerClientEvent is used on the server side to trigger events from the client side. I shouldn't be on forums when I'm tired or on my phone... but yes, triggerServerEvent. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now