Jump to content

مساعده في اسكربتgetElementData


Tarek1

Recommended Posts

Error : Bad argument @ 'getElementData' [ Expected element at argument 1 , got string ' warzone ' ]

--Server side


function enterWarZone(p)
if WarZoneStatus ==  true and not AllowedToEnter[getElementData(p,"Job")] then  exports.URGMessages:sendClientMessage("Events : Only Police Criminals can enter",thePlayer,255,0,0) return end
if not (WarZoneStatus) then  exports.URGMessages:sendClientMessage("Events : War Zone Not Started ",p,255,0,0) return end
if WarZoneStatus == true and isTimer(WarZoneTime) then 
local xx,yy,zz = getElementPosition(p)
setElementData(p,"JoinedEventPos",{xx,yy,zz})
local x, y, z = unpack(spawn[getElementData(p,"Job")][math.random(#spawn[getElementData(p,"Job")])])
setElementData(p,"inWZ",true)
setElementPosition(p, x, y, z)
setElementDimension(p,66)
   end
end

 

Edited by Tarek1
Link to comment
10 hours ago, 3laa33 said:

حط السطر اللي تنادي فيه الفنكشن

  1.  
  2. function enterWarZone(p)
  3. if WarZoneStatus == true and not AllowedToEnter[getElementData(p,"Job")] then exports.URGMessages:sendClientMessage("Events : Only Police Criminals can enter",thePlayer,255,0,0) return end
  4. if not (WarZoneStatus) then exports.URGMessages:sendClientMessage("Events : War Zone Not Started ",p,255,0,0) return end
  5. if WarZoneStatus == true and isTimer(WarZoneTime) then
  6. local xx,yy,zz = getElementPosition(p)
  7. setElementData(p,"JoinedEventPos",{xx,yy,zz})
  8. local x, y, z = unpack(spawn[getElementData(p,"Job")][math.random(#spawn[getElementData(p,"Job")])])
  9. setElementData(p,"inWZ",true)
  10. setElementPosition(p, x, y, z)
  11. setElementDimension(p,66)
  12. end
  13. end
  14. addEvent("onHit",true)
  15. addEventHandler("onHit",getRootElement(),enterWarZone)
Link to comment
Just now, Tarek1 said:

triggerServerEvent("onHit",localPlayer,guiGridListGetItemText(evGrid, r, 1),"JoinEvent")

حط الكلينت كامل اسهل من كل شوي نطلب كود
او 
حط الكود اللي تملي فيه الجريد ليست

Link to comment
--Client Side

["events"] = {
function () 
if not rendered then
    local evGrid = guiCreateGridList(0.42, 0.28, 0.16, 0.24, true)
    guiGridListAddColumn(evGrid, "Name:", 0.9)    
    for k, v in pairs(events) do    
    local r = guiGridListAddRow(evGrid,v[1]) 
    end
    local evStop = guiCreateButton(0.51, 0.70, 0.08, 0.04, "Stop Event", true)
    local evStart = guiCreateButton(0.42, 0.70, 0.08, 0.04, "Start event", true)
    local evJoin = guiCreateButton(0.42, 0.66, 0.08, 0.04, "Join event", true)
    local evLeave = guiCreateButton(0.51, 0.66, 0.08, 0.04, "Leave Event", true)
    addEventHandler("onClientGUIClick", evJoin, function ()
        if guiGridListGetSelectedItem(evGrid) >= 0 then
        local r = guiGridListGetSelectedItem(evGrid)    
      triggerServerEvent("onHit",localPlayer,guiGridListGetItemText(evGrid, r, 1),"JoinEvent")

    else
       exports.URGMessages:sendClientMessage("Events: Please select an event",255,0,0)
    end
    
end)

 

--Server side
function enterWarZone(p)
if WarZoneStatus ==  true and not AllowedToEnter[getElementData(p,"Job")] then  exports.URGMessages:sendClientMessage("Events : Only Government/Terrorists/Gangster/Police can join warzone",thePlayer,255,0,0) return end
if not (WarZoneStatus) then  exports.URGMessages:sendClientMessage("Events : War Zone Not Started ",p,255,0,0) return end
if WarZoneStatus == true and isTimer(WarZoneTime) then 
local xx,yy,zz = getElementPosition(p)
setElementData(p,"JoinedEventPos",{xx,yy,zz})
local x, y, z = unpack(spawn[getElementData(p,"Job")][math.random(#spawn[getElementData(p,"Job")])])
setElementData(p,"inWZ",true)
setElementPosition(p, x, y, z)
setElementDimension(p,66)
   end
end
addEvent("enterWarZone",true)
addEventHandler("enterWarZone",root,enterWarZone)

 

Edited by Tarek1
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...