Jump to content

GUI help


mint3d

Recommended Posts

Posted

Ok i have a SWAT job but everybody see the GUI when i walk in and when it says You must be in SWAT to do this everybody can see also

Client;

local marker = createMarker( 1288.7602539063, -1642.1657714844, 12.5, "Cylinder", 1.4, 0, 0, 255, 255) 
      
  
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
GUIEditor_Label = {} 
  
function guiMyCwindow(w,h,t) 
local x,y = guiGetScreenSize() 
return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) 
end 
  
  
showCursor(false) 
windowjob = guiMyCwindow(301,170,"[sGN] SWAT Team ") 
guiSetVisible(windowjob, false) 
GUIEditor_Button[1] = guiCreateButton(22,80,108,35,"Take job",false,windowjob) 
GUIEditor_Button[3] = guiCreateButton(22,120,108,35,"Quit Job",false,windowjob) 
GUIEditor_Button[2] = guiCreateButton(179,120,110,36,"Cancel",false,windowjob) 
GUIEditor_Label[1] = guiCreateLabel(19,33,273,20,"Are you sure you want to take/leave this job?",false,windowjob) 
  
function SWATjob ( hitElement ) 
if (getElementType(hitElement) == 'player' ) then 
if getPlayerTeam(hitElement) and getTeamName(getPlayerTeam(hitElement)) == "SWAT"  then 
guiSetVisible(windowjob, true) 
showCursor(true) 
else 
 outputChatBox ("You Must Be on SWAT Team To Do This ",255, 0, 0) 
        end 
    end 
end 
addEventHandler("onClientMarkerHit", marker, SWATjob ) 
  
function SWATjobleave(leaveElement) 
if (getElementType(leaveElement) == 'player' ) then 
guiSetVisible(windowjob, false) 
showCursor(false) 
end 
end 
addEventHandler("onClientMarkerLeave", marker, SWATjobleave) 
  
function joinTeam() 
triggerServerEvent("setSWAT",localPlayer) 
guiSetVisible(windowjob, false) 
showCursor(false) 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) 
  
function removeTeam() 
triggerServerEvent("removeSWAT",localPlayer) 
guiSetVisible(windowjob, false) 
showCursor(false) 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[3] , removeTeam, false) 
  
function removeSWATWindow() 
guiSetVisible(windowjob, false) 
showCursor(false) 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSWATWindow, false) 
  

Server;

  
function createSWATTeam () 
    SWATteam = createTeam ("SWAT", 0, 0, 255) 
end 
addEventHandler ("onResourceStart", resourceRoot, createSWATTeam) 
  
function joinSWAT() 
     setPlayerTeam(source,SWATteam) 
     setElementModel(source, 285) 
      giveWeapon ( source, 3 ) 
      playeraccount = getPlayerAccount( source ) 
     setAccountData( playeraccount, "team", "SWAT", true ) 
     outputChatBox("You are now SWAT.",source,0,0,255) 
end 
addEvent("setSWAT", true) 
addEventHandler("setSWAT",root,joinSWAT) 
  
 function removeSWAT() 
    setPlayerTeam(source, 0) 
    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.",source,255,0,0) 
    end 
    addEvent("removeSWAT", true) 
    addEventHandler("removeSWAT",root,removeSWAT) 
  
function SWATJob ( attacker, attackerweapon, bodypart, loss ) 
 if attacker and getElementType(attacker) == "player" then 
        theTeam = getPlayerTeam ( attacker ) 
        theWL = getPlayerWantedLevel ( source ) 
        theSkin = getElementModel ( attacker ) 
        if (attackerweapon == 3) and (loss > 2 ) and (theWL > 0) then 
            if  getTeamName( theTeam ) == "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 60 seconds.", source ) 
                local playeraccount = getPlayerAccount ( attacker ) 
                givePlayerMoney (attacker, 100) 
                setTimer ( setElementPosition, 60000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439)       
                setPlayerWantedLevel (source, 0) 
                end 
            end 
        end 
    end 
    addEventHandler ("onPlayerDamage", getRootElement(), policeJob) 

Skype: Jordan_Nymph

Posted

That's because you aren't checking if the hit element is the local player at "SWATjob" function.

In this line:

if (getElementType(hitElement) == 'player' ) then 

You can add:

if ( hitElement == localPlayer and getElementType ( hitElement ) == 'player' ) then 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, instead of using getPlayerTeam + getTeamName, use:

getElementData ( hitElement, "gang" ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
if getPlayerTeam(hitElement) and getTeamName(getPlayerTeam(hitElement)) == "SWAT"  then 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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