Jump to content

setElementData


Gtagasje

Recommended Posts

Hi,

I have a script that will set you to the police team if you click the gui button, and I tried to set the ElementData to "Officer"

but it shows the following error : Bad argument @ setElementData ( line 8 ) [Expected element @ argument 1, got nill.]

This is my server sided script :

  
local Police = createTeam ("Police", 0, 0, 255) 
  
function SetPlayerPolice() 
  
 setPlayerTeam (source, getTeamFromName("Police")) 
 setElementModel (source, 280) 
 giveWeapon ( source, 22, 15 ) 
 setElementData ( thePlayer, "Officer", true ) 
  
end 
  
addEvent("PoliceTeam",true) 
  
addEventHandler("PoliceTeam", root, SetPlayerPolice) 
  

And if you need it, client side:

  
local dutyMarker = createMarker ( 1547.88953, -1681.53955, 12.5, 'cylinder', 2.0, 0, 0, 225, 132 ) 
  
  
  
function createCopGui ( hitElement ) 
  
        PoliceGui = guiCreateWindow(227,106,342,376,"MLAW Police job",false) 
  
        Have_Job = guiCreateButton(39,313,111,45,"Have job!",false,PoliceGui) 
  
        Cancel = guiCreateButton(200,312,111,45,"Cancel",false,PoliceGui) 
  
        Doel = guiCreateMemo(63,44,234,242,"Police Job:\nAs police you will have a hourly payment. Further objectves comming soon!",false,PoliceGui) 
  
        guiMemoSetReadOnly( Doel,true ) 
  
end 
  
  
  
addEventHandler("onClientMarkerHit", dutyMarker, 
  
 function( hitElement ) 
  
            if hitElement == localPlayer then 
  
            createCopGui ( hitElement ) 
  
            if (PoliceGui ~= nil) then 
  
            guiSetVisible(PoliceGui, true) 
  
            showCursor(true) 
  
            guiSetInputEnabled(true) 
  
            else 
  
            outputChatBox ("The police doesn't want you. Please re-enter the marker.") 
  
            end 
  
        end 
  
    end 
  
) 
  
function PoliceTeam(button,state) 
  
 if (source == Have_Job) then 
  
          triggerServerEvent("PoliceTeam",localPlayer) 
  
          guiSetInputEnabled(false) 
  
          guiSetVisible(PoliceGui, false) 
  
          showCursor(false) 
           
          outputChatBox ( "Police Commander: Welcome to the police team!" ) 
           
          outputChatBox ( "Police Ammunation: You have been given 15 pistol ammo for self defence!" ) 
  
 elseif (source == Cancel) then 
  
          guiSetInputEnabled(false) 
  
          guiSetVisible(PoliceGui, false) 
  
          showCursor(false) 
  
     end 
  
end 
  
addEventHandler ("onClientGUIClick", root, PoliceTeam) 
  

I have alot of spaces, dont know why.

Link to comment

try this

local Police = createTeam ("Police", 0, 0, 255) 
  
function SetPlayerPolice() 
  
 setPlayerTeam (source, getTeamFromName("Police")) 
 setElementModel (source, 280) 
 giveWeapon ( source, 22, 15 ) 
 setElementData ( source, "Officer",true ) 
  
end 
  
addEvent("PoliceTeam",true) 
  
addEventHandler("PoliceTeam", root, SetPlayerPolice) 

Link to comment

It now wants a element at argument 3.. :S and, I want it to go to the "rank" column, which I added in the dxscoreboard_exports script. Here's the lines:

  
scoreboardColumns = { 
    { ["name"] = "name", ["width"] = 200, ["friendlyName"] = "Name", ["priority"] = 1 }, 
    { ["name"] = "ping", ["width"] = 40, ["friendlyName"] = "Ping", ["priority"] = MAX_PRIRORITY_SLOT }, 
    { ["name"] = "rank", ["width"] = 100, ["friendlyName"] = "rank", ["priority"] = 2 } 
} 
  

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