Jump to content

criminal job


Recommended Posts

hi all i make criminl job but when criminal player kill player he not get wanted level why??

here is code

local marker = createMarker( 2000.763671875, 1539.0169677734, 13.5859375, "Cylinder", 1.5, 0, 0, 0, 10) 
local ped = createPed          (21, 2000.6636962891, 1538.318359375, 13.5859375) 
createBlip (2000.763671875, 1539.0169677734, 13.5859375, 23 ,2 ) 
                    myFont = dxCreateFont( "SF Automaton Bold.ttf", 20 )  -- Create custom font 
  
  
  
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
GUIEditor_gridlist = {} 
  
        windowjob = guiCreateWindow(392, 176, 408, 437, "Criminal Job", false) 
        guiWindowSetSizable(windowjob, false) 
guiSetVisible(windowjob, false) 
        GUIEditor_Memo[1] = guiCreateMemo(18, 30, 362, 221, "Hi,\nFeatures of Criminal job :\n-Turf with your Gang\n-\n-\nDo you want to join ?", false, windowjob) 
        guiMemoSetReadOnly(GUIEditor_Memo[1], true) 
        GUIEditor_gridlist[1] = guiCreateGridList(21, 264, 359, 115, false, windowjob) 
        guiGridListAddColumn(GUIEditor_gridlist[1], "ID", 0.5) 
        guiGridListAddColumn(GUIEditor_gridlist[1], "Skin Name", 0.5) 
        for i = 1, 5 do 
            guiGridListAddRow(GUIEditor_gridlist[1]) 
        end 
        guiGridListSetItemText(GUIEditor_gridlist[1], 0, 1, "29", false, false) 
        guiGridListSetItemText(GUIEditor_gridlist[1], 0, 2, "White Dealer", false, false) 
        guiGridListSetItemText(GUIEditor_gridlist[1], 1, 1, "28", false, false) 
        guiGridListSetItemText(GUIEditor_gridlist[1], 1, 2, "Black Dealer", false, false) 
        guiGridListSetItemText(GUIEditor_gridlist[1], 2, 1, "19", false, false) 
        guiGridListSetItemText(GUIEditor_gridlist[1], 2, 2, "Beach Gangsta", false, false) 
        guiGridListSetItemText(GUIEditor_gridlist[1], 3, 1, "21", false, false) 
        guiGridListSetItemText(GUIEditor_gridlist[1], 3, 2, "Striped Gangsta", false, false) 
        guiGridListSetItemText(GUIEditor_gridlist[1], 4, 1, "47", false, false) 
        guiGridListSetItemText(GUIEditor_gridlist[1], 4, 2, "Top Button Essey", false, false) 
        GUIEditor_Button[1] = guiCreateButton(21, 379, 175, 48, "Take job !", false, windowjob) 
        GUIEditor_Button[2] = guiCreateButton(206, 379, 174, 48, "Cancel", false, windowjob) 
         
function SAPDjob(hitElement) 
                setElementData ( localPlayer, "ownskin", getElementModel (localPlayer)  ) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
    if not guiGetVisible(windowjob) then 
        guiSetVisible(windowjob, true) 
                      showCursor(true) 
                  end 
             end 
        end 
        addEventHandler("onClientMarkerHit", marker, SAPDjob) 
          
        function FBIjobleave(leaveElement) 
         
             if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then 
                  if guiGetVisible(windowjob) then 
                       guiSetVisible(windowjob, false) 
                       showCursor(false) 
                  end 
             end 
        end 
        addEventHandler("onClientMarkerLeave", marker, SAPDjobleave) 
        function setskintest() 
        local skin = guiGridListGetItemText ( GUIEditor_gridlist[1], guiGridListGetSelectedItem ( GUIEditor_gridlist[1] ), 1 ) 
        setElementModel ( localPlayer, skin ) 
        end 
             addEventHandler ( "onClientGUIClick", GUIEditor_gridlist[1], setskintest, false ) 
        function joinTeam() 
             triggerServerEvent("gov",localPlayer) 
             local skin = guiGridListGetItemText ( GUIEditor_gridlist[1], guiGridListGetSelectedItem ( GUIEditor_gridlist[1] ), 1 ) 
             if skin ~= 0 or getElementData(localPlayer, "ownskin") then 
             guiSetVisible(windowjob, false) 
             showCursor(false) 
             setElementModel ( localPlayer, skin ) 
             else 
             exports["TopBarChat"]:sendClientMessage ("You didn't select a Skin", 255, 0, 0 ) 
              
        end 
        end 
        addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) 
          
        function removeSAPDWindow() 
        guiSetVisible(windowjob, false) 
        showCursor(false) 
        setElementModel(localPlayer, getElementData(localPlayer, "ownskin")) 
              
        end 
         
         
        addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSAPDWindow, false) 
  
     local maxDistance = 12 -- the distance showing 3dtext 
   local ped = createPed (21, 2000.6636962891, 1538.318359375, 13.5859375) 
      
    addEventHandler ( "onClientRender", root, 
        function ( ) 
     local pX, pY, pZ = getElementPosition ( localPlayer ) 
            local pedX, pedY, pedZ = getElementPosition ( ped ) 
            local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) 
            
            if ( distance <= 12 ) then 
                local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) 
                if ( x and y ) then 
                dxDrawText( "Criminal", x, y+1.5, _, _, tocolor( 255, 0, 0, 255 ), 1, myFont, "center", "center" ) 
                end 
            end 
        end 
    ) 

function createSAPDTeam () 
    SAPDteam = createTeam ("Criminal", 255, 0, 0) 
end 
  
function joincriminal() 
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Everyone")) then 
local wlevel = getPlayerWantedLevel( source ) 
end 
end 
addEventHandler ("onResourceStart", resourceRoot, createSAPDTeam) 
  
function joinSAPD() 
     setPlayerTeam(source,SAPDteam) 
     setElementFrozen ( ped, true ) 
     setElementHealth ( ped, 180 ) 
     giveWeapon ( source, 3 ) 
     giveWeapon ( source, 31,2500 ) 
     setElementData( source, "Occupation", "Government", true ) 
     setElementData ( source, "Rank", "Federal Agent" ) 
end 
addCommandHandler("criminal",joinSAPD) 
addEvent("gov", true) 
addEventHandler("gov",root,joinSAPD) 

anyone tell how i do this

Link to comment

There is no setPlayerWantedLevel in your code.

This is a very old code that I have, it's not perfect but it should do the job:

addEventHandler("onPlayerDamage", root, 
    function(attacker,weapon,bodypart,loss) 
        if not attacker or attacker == source or getElementType ( attacker ) ~= "player" then return end 
        setPlayerWantedLevel(attacker, getPlayerWantedLevel(attacker) + 1) 
    end 
) 

It still needs several checks, but that's for you to add.

Link to comment

Or just use the onPlayerWasted event.

  
    addEventHandler("onPlayerWasted", root, 
        function(_,killer) 
            if getElementType(killer) == "player" then 
                            setPlayerWantedLevel(killer,getPlayerWantedLevel(killer) + 1) 
            end 
        end 
    ) 

Link to comment

No matter what, as soon your value goes above 6 that function will just return an error:

addEventHandler("onPlayerWasted", root, 
        function(_,killer) 
            if getElementType(killer) == "player" then 
                if getPlayerWantedLevel(killer) < 6 then 
                    setPlayerWantedLevel(killer,getPlayerWantedLevel(killer) + 1) 
                else 
                    setPlayerWantedLevel(killer,6)  
                end 
            end 
        end 
    ) 

Always remember to check if it's possible to go one step further. Another solution could be to store the actual wanted level as element data and then just use the stars as a visual effect.

Link to comment

thanks guys

i am thinking to upgrade this criminals job as JR10 say it old code and can you tell me how i make criminals rank (EX:when player join Criminals job he do 100 illegel thing then he get next rank i just added rank name on code or also show rank on tab)

anymore idea pls tell me how to make it

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