Jump to content

Help Me Please With My First Job!!


Recommended Posts

Ok so basically i started to script my first job and its a police job!

Everything works fine no problems in /debugscript 3 neither console!

Only thing is i created a marker but it don't appear?

Can somone please help me this is urgent!!!

Server Side

  
createBlip ( 1565, -1676, 62, 30 ) 
  
function createPDTeam () 
    PDteam = createTeam ("Los Santos Police", 100, 149, 237) 
end 
addEventHandler ("onResourceStart", resourceRoot, createPDTeam) 
  
function joinPD() 
     setPlayerTeam(source,PDteam) 
     setElementModel(source, 280) 
      giveWeapon ( source, 64, 2000 ) 
      playeraccount = getPlayerAccount( source ) 
     setAccountData( playeraccount, "team", "Los Santos Police", true ) 
     outputChatBox("You are now part of LSPD!",source,0,255,0) 
end 
addEvent("setPD", true) 
addEventHandler("setPD",root,joinPD) 
  
function removePD() 
    setPlayerTeam(source, 0) 
    takeWeapon(source, 64) 
    playeraccount = getPlayerAccount(source) 
    if getAccountData(playeraccount, "standardskin") == 0 then 
    setElementModel(source, 0) 
    else 
    setElementModel(source,getAccountData(playeraccount,"standardskin")) 
     end 
     outputChatBox("You are now an unemployed from this job.",source,255,0,0) 
    end 
    addEvent("removePD", true) 
    addEventHandler("removePD",root,removePD) 
     
function policeJob ( attacker, attackerweapon, bodypart, loss ) 
 if attacker and getElementType(attacker) == "player" then 
        theTeam = getPlayerTeam ( attacker ) 
        theWL = getPlayerWantedLevel ( source ) 
        theSkin = getElementModel ( attacker ) 
        if (attackerweapon == 6) and (loss > 2 ) and (theWL > 0) then 
            if  getTeamName( theTeam ) == "Los Santos Police" or getTeamName( theTeam ) == "SWAT" or getTeamName( theTeam ) == "FBI" then 
                setElementPosition (source, 4076.3999023438, -1788.5, 3.511967, true) 
                theName = getPlayerName ( source ) 
                theCop = getPlayerName ( attacker )   
                outputChatBox ( "You have been jailed by "..theCop.. " for 10 seconds.", source ) 
                local playeraccount = getPlayerAccount ( attacker ) 
                givePlayerMoney (attacker, 100) 
                setTimer ( setElementPosition, 10000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439)       
                setPlayerWantedLevel (source, 0) 
                end 
            end 
        end 
    end 
    addEventHandler ("onPlayerDamage", getRootElement(), policeJob) 
  
  

Client Side

local jobmarker = createMarker(1552.4996337891, -1677.3264160156, 15.1953125, "Cylinder", 1.5, 0, 0, 255, 150) 
  
  
GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
} 
  
    function guiMyCwindow() 
        windowjob = guiCreateWindow(272, 191, 276, 291, "LS Police") 
        guiSetVisible(windowjob, false) 
        guiWindowSetMovable(GUIEditor.window[1], false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 0.78) 
  
        GUIEditor.memo[1] = guiCreateMemo(9, 24, 258, 98, "Welcome to the Los Santos Police Department Job! Accept or Decline the job!\nAccept : Help the city survive from criminals!\nDecline: Bye! See You Soon!!", false, GUIEditor.window[1]) 
        guiMemoSetReadOnly(GUIEditor.memo[1], true) 
        GUIEditor.button[1] = guiCreateButton(10, 240, 82, 35, "Accept", false, GUIEditor.window[1]) 
        GUIEditor.button[2] = guiCreateButton(182, 240, 75, 35, "Decline", false, GUIEditor.window[1]) 
        GUIEditor.button[11] = guiCreateButton(95, 225, 82, 23, "Quit Job", false, GUIEditor.window[20]) 
  
  
        function PDjob(hitElement) 
             if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
                  if not guiGetVisible(windowjob) then 
                       guiSetVisible(windowjob, true) 
                       showCursor(true) 
                  end 
             end 
        end  
    end 
) 
addEventHandler("onClientMarkerHit", jobmarker, PDjob) 
  
function PDjobleave(leaveElement) 
             if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then 
                  if guiGetVisible(windowjob) then 
                       guiSetVisible(windowjob, false) 
                       showCursor(false) 
                  end 
             end 
        end 
        addEventHandler("onClientMarkerLeave", jobmarker, PDjobleave) 
         
        function joinTeam() 
             triggerServerEvent("setPD",localPlayer) 
             guiSetVisible(windowjob, false) 
             showCursor(false) 
        end 
        addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) 
         
        function removeTeam() 
    triggerServerEvent("removePD",localPlayer) 
    guiSetVisible(windowjob, false) 
    showCursor(false) 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[11] , removeTeam, false) 
  
 function removePDWindow() 
             guiSetVisible(windowjob, false) 
             showCursor(false) 
        end 
        addEventHandler("onClientGUIClick", GUIEditor_Button[11] , removePDWindow, false) 

Link to comment

Well, there were many errors, one caused the script to don't even start, so, next time you really should pay more attention.

local jobmarker = createMarker(1552.4996337891, -1677.3264160156, 15.1953125, "cylinder", 1.5, 0, 0, 255, 150) 
  
  
GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
} 
  
function guiMyCwindow() 
    windowjob = guiCreateWindow(272, 191, 276, 291, "LS Police") 
    guiSetVisible(windowjob, false) 
    guiWindowSetMovable(GUIEditor.window[1], false) 
    guiWindowSetSizable(GUIEditor.window[1], false) 
    guiSetAlpha(GUIEditor.window[1], 0.78) 
  
    GUIEditor.memo[1] = guiCreateMemo(9, 24, 258, 98, "Welcome to the Los Santos Police Department Job! Accept or Decline the job!\nAccept : Help the city survive from criminals!\nDecline: Bye! See You Soon!!", false, GUIEditor.window[1]) 
    guiMemoSetReadOnly(GUIEditor.memo[1], true) 
    GUIEditor.button[1] = guiCreateButton(10, 240, 82, 35, "Accept", false, GUIEditor.window[1]) 
    GUIEditor.button[2] = guiCreateButton(182, 240, 75, 35, "Decline", false, GUIEditor.window[1]) 
    GUIEditor.button[11] = guiCreateButton(95, 225, 82, 23, "Quit Job", false, GUIEditor.window[20]) 
    addEventHandler("onClientGUIClick", GUIEditor.button[1] , joinTeam, false) 
    addEventHandler("onClientGUIClick", GUIEditor.button[11] , removePDWindow, false) 
    addEventHandler("onClientGUIClick", GUIEditor.button[11] , removeTeam, false) 
end 
  
function PDjob(hitElement) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
        if not guiGetVisible(windowjob) then 
            guiSetVisible(windowjob, true) 
            showCursor(true) 
        end 
    end 
end 
addEventHandler("onClientMarkerHit", jobmarker, PDjob) 
  
function PDjobleave(leaveElement) 
    if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then 
        if guiGetVisible(windowjob) then 
            guiSetVisible(windowjob, false) 
            showCursor(false) 
        end 
    end 
end 
addEventHandler("onClientMarkerLeave", jobmarker, PDjobleave) 
  
function joinTeam() 
    triggerServerEvent("setPD",localPlayer) 
    guiSetVisible(windowjob, false) 
    showCursor(false) 
end 
  
function removeTeam() 
    triggerServerEvent("removePD",localPlayer) 
    guiSetVisible(windowjob, false) 
    showCursor(false) 
end 
  
function removePDWindow() 
    guiSetVisible(windowjob, false) 
    showCursor(false) 
end 

Link to comment
local jobmarker = createMarker(1552.4996337891, -1677.3264160156, 15.1953125, "cylinder", 1.5, 0, 0, 255, 150) 
  
  
GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
} 
  
function guiMyCwindow() 
    windowjob = guiCreateWindow(272, 191, 276, 291, "LS Police") 
    guiSetVisible(windowjob, false) 
    guiWindowSetMovable(GUIEditor.window[1], false) 
    guiWindowSetSizable(GUIEditor.window[1], false) 
    guiSetAlpha(GUIEditor.window[1], 0.78) 
  
    GUIEditor.memo[1] = guiCreateMemo(9, 24, 258, 98, "Welcome to the Los Santos Police Department Job! Accept or Decline the job!\nAccept : Help the city survive from criminals!\nDecline: Bye! See You Soon!!", false, GUIEditor.window[1]) 
    guiMemoSetReadOnly(GUIEditor.memo[1], true) 
    GUIEditor.button[1] = guiCreateButton(10, 240, 82, 35, "Accept", false, GUIEditor.window[1]) 
    GUIEditor.button[2] = guiCreateButton(182, 240, 75, 35, "Decline", false, GUIEditor.window[1]) 
    GUIEditor.button[11] = guiCreateButton(95, 225, 82, 23, "Quit Job", false, GUIEditor.window[20]) 
    addEventHandler("onClientGUIClick", GUIEditor.button[1] , joinTeam, false) 
    addEventHandler("onClientGUIClick", GUIEditor.button[11] , removePDWindow, false) 
    addEventHandler("onClientGUIClick", GUIEditor.button[11] , removeTeam, false) 
    addEventHandler( "onClientResourceStart", resourceRoot, guiMyCwindow) 
end 
  
function PDjob(hitElement) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
        if not guiGetVisible(windowjob) then 
            guiSetVisible(windowjob, true) 
            showCursor(true) 
        end 
    end 
end 
addEventHandler("onClientMarkerHit", jobmarker, PDjob) 
  
function PDjobleave(leaveElement) 
    if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then 
        if guiGetVisible(windowjob) then 
            guiSetVisible(windowjob, false) 
            showCursor(false) 
        end 
    end 
end 
addEventHandler("onClientMarkerLeave", jobmarker, PDjobleave) 
  
function joinTeam() 
    triggerServerEvent("setPD",localPlayer) 
    guiSetVisible(windowjob, false) 
    showCursor(false) 
end 
  
function removeTeam() 
    triggerServerEvent("removePD",localPlayer) 
    guiSetVisible(windowjob, false) 
    showCursor(false) 
end 
  
function removePDWindow() 
    guiSetVisible(windowjob, false) 
    showCursor(false) 
end 

Link to comment
where do i add this?

Did you even read my post?

guiMyCwindow is never called.

Line 26:

addEventHandler( "onClientResourceStart", resourceRoot, guiMyCwindow); 

People get so lazy these days.

@Razor,

Your code is wrong.

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