Hero192 Posted July 4, 2015 Share Posted July 4, 2015 (edited) Hello guys, my problem is i want to let only the Criminal team who click the ped and get the gui but in this code criminal team and non criminal team are not able to take the job i tried also with if getTeamName(getPlayerTeam(element)) == "Criminal" then returns but it doesn't works too ,any one have an idea please? function onPedClick(button, state, absX, absY, wx, wy, wz, element) if element and getElementType(element) == "ped" and state=="down" and button=="left" then local x, y, z = getElementPosition(element) if getTeamName(getPlayerTeam(element)) ~= "Criminal" then outputChatBox("You must be criminal .",255,0,0) return end if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz)<=3 then guiSetVisible(Window,true) end end end end addEventHandler("onClientClick", getRootElement(), onPedClick,true ) WARNING: Bad argument @ 'getPlayerTeam'[expected player at argument 1,got ped) Edited July 4, 2015 by Guest Link to comment
bosslorenz Posted July 4, 2015 Share Posted July 4, 2015 Try this. function onPedClick(button, state, absX, absY, wx, wy, wz, element) local pTeam = getPlayerTeam ( element ) if pTeam then local tName = getTeamName(pTeam) local x, y, z = getElementPosition(element) if ( tName ~= "Criminal" ) then cancelEvent() outputChatBox("You must be criminal .",255,0,0) else if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz)<=3 then guiSetVisible(Window,true) end end end end addEventHandler("onClientClick", getRootElement(), onPedClick) Link to comment
Hero192 Posted July 4, 2015 Author Share Posted July 4, 2015 Doesn't works it give warning in debug like in my code Bad argument @ 'getPlayerTeam'[expected player at argument 1,got ped) Link to comment
bosslorenz Posted July 4, 2015 Share Posted July 4, 2015 LINE NUMBER ON/OFF | EXPAND/CONTRACT | SELECT ALL function onPedClick(button, state, absX, absY, wx, wy, wz, player) local pTeam = getPlayerTeam ( player ) if pTeam then local tName = getTeamName(pTeam) local x, y, z = getElementPosition(player) if ( tName ~= "Criminal" ) then cancelEvent() outputChatBox("You must be criminal .",255,0,0) else if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz)<=3 then guiSetVisible(Window,true) end end end end addEventHandler("onClientClick", getRootElement(), onPedClick) 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