Jump to content

[HELP] How to make GUI Window pop-up for 1 player


Recommended Posts

Posted (edited)

Hi, I made the script and everything...

& it works! But if someone stands in it the GUI pops up for everybody O_O

I know it has to be something with localplayer but i dont know where...

Here is the Server - Sided & Client - Sided Script

SERVER SIDED:

--LSAmmu-Nation
---------------
createBlip ( 1536.0153808594, -1476.4598388672, 8.5, 6 )
 
function gw(weapon,ammo)
giveWeapon ( source, weapon, ammo )
playSoundFrontEnd ( source, 17 )
end
 
addEvent( "giveweapon", true )
addEventHandler( "giveweapon", getRootElement(), gw )

HERE IS THE CLIENT - SIDE:

--LS Ammu-Nation
----------------
GUIEditor_Window = {}
GUIEditor_Button = {}
GUIEditor_Label = {}
GUIEditor_Grid = {}
GUIEditor_Image = {}
 
function menu_close()
showCursor(false)
guiSetVisible( GUIEditor_Window[1], false )
end
 
function menu_show()
guiSetVisible( GUIEditor_Window[1], true )
end
 
local mar = createMarker ( 1536.0153808594, -1476.4598388672, 8.5, 255, 1, 136, 79, 1 )
function markertarget()
setMarkerTarget ( mar, 1536.0153808594, -1476.4598388672, 8.5 )
end
 
function MarkerHit( hitPlayer, matchingDimension )
local x,y,z = getMarkerTarget( source, mar )    -- get the marker target
if x ~= false then
 
if getElementType(hitPlayer)=="player" then
showCursor(true)
 
--GUI
  GUIEditor_Window[1] = guiCreateWindow(0.2109,0.3112,0.5957,0.3984,"Stuff from Holland!",true)
guiWindowSetSizable(GUIEditor_Window[1],false)
  GUIEditor_Grid[1] = guiCreateGridList(0.023,0.1176,0.2328,0.3529,true,GUIEditor_Window[1])
guiGridListSetSelectionMode(GUIEditor_Grid[1],2)
  GUIEditor_Image[1] = guiCreateStaticImage(0.2535,0.0741,0.4718,0.5463,"IMG/DEAGLE.png",true,GUIEditor_Grid[1])
  GUIEditor_Label[1] = guiCreateLabel(0.0563,0.0648,0.3944,0.1852,"50$",true,GUIEditor_Grid[1])
guiLabelSetColor(GUIEditor_Label[1],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false)
  GUIEditor_Label[2] = guiCreateLabel(0.0563,0.0648,0.3944,0.1852,"50$",true,GUIEditor_Grid[1])
guiLabelSetColor(GUIEditor_Label[2],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false)
  GUIEditor_Grid[2] = guiCreateGridList(0.2656,0.1176,0.2328,0.3529,true,GUIEditor_Window[1])
guiGridListSetSelectionMode(GUIEditor_Grid[2],2)
  GUIEditor_Image[2] = guiCreateStaticImage(0.2676,0.1204,0.4789,0.5556,"IMG/MICROUZI.png",true,GUIEditor_Grid[2])
  GUIEditor_Label[3] = guiCreateLabel(0.0704,0.0648,0.3451,0.1759,"100$",true,GUIEditor_Grid[2])
guiLabelSetColor(GUIEditor_Label[3],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false)
  GUIEditor_Grid[3] = guiCreateGridList(0.5082,0.1176,0.2328,0.3529,true,GUIEditor_Window[1])
guiGridListSetSelectionMode(GUIEditor_Grid[3],2)
  GUIEditor_Image[3] = guiCreateStaticImage(0.2606,0.1481,0.5211,0.5556,"IMG/M4.png",true,GUIEditor_Grid[3])
  GUIEditor_Button[3] = guiCreateButton(0.0986,0.7037,0.8028,0.2222,"M4",true,GUIEditor_Grid[3])
  GUIEditor_Label[4] = guiCreateLabel(0.0634,0.0741,0.3873,0.1667,"500$",true,GUIEditor_Grid[3])
guiLabelSetColor(GUIEditor_Label[4],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[4],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[4],"left",false)
  GUIEditor_Grid[4] = guiCreateGridList(0.023,0.4869,0.2328,0.3529,true,GUIEditor_Window[1])
guiGridListSetSelectionMode(GUIEditor_Grid[4],2)
  GUIEditor_Image[4] = guiCreateStaticImage(0.2746,0.1019,0.4225,0.5556,"IMG/COLT45.png",true,GUIEditor_Grid[4])
  GUIEditor_Label[5] = guiCreateLabel(0.0563,0.0833,0.4225,0.1574,"50$",true,GUIEditor_Grid[4])
guiLabelSetColor(GUIEditor_Label[5],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[5],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[5],"left",false)
  GUIEditor_Grid[5] = guiCreateGridList(0.2672,0.4902,0.2328,0.3529,true,GUIEditor_Window[1])
guiGridListSetSelectionMode(GUIEditor_Grid[5],2)
  GUIEditor_Button[5] = guiCreateButton(0.0915,0.6944,0.7958,0.2222,"MP5",true,GUIEditor_Grid[5])
  GUIEditor_Image[5] = guiCreateStaticImage(0.2606,0.1019,0.4296,0.5185,"IMG/MP5.png",true,GUIEditor_Grid[5])
  GUIEditor_Label[6] = guiCreateLabel(0.0634,0.0741,0.338,0.1574,"300$",true,GUIEditor_Grid[5])
guiLabelSetColor(GUIEditor_Label[6],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[6],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[6],"left",false)
  GUIEditor_Grid[6] = guiCreateGridList(0.5098,0.4902,0.2328,0.3529,true,GUIEditor_Window[1])
guiGridListSetSelectionMode(GUIEditor_Grid[6],2)
  GUIEditor_Image[6] = guiCreateStaticImage(0.2535,0.1019,0.5282,0.5463,"IMG/AK47.png",true,GUIEditor_Grid[6])
  GUIEditor_Label[7] = guiCreateLabel(0.0704,0.0741,0.3451,0.1667,"400$",true,GUIEditor_Grid[6])
guiLabelSetColor(GUIEditor_Label[7],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[7],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[7],"left",false)
  GUIEditor_Grid[7] = guiCreateGridList(0.7525,0.4869,0.2246,0.3529,true,GUIEditor_Window[1])
guiGridListSetSelectionMode(GUIEditor_Grid[7],2)
  GUIEditor_Image[7] = guiCreateStaticImage(0.1679,0.1019,0.5547,0.5648,"IMG/SNIPER.png",true,GUIEditor_Grid[7])
  GUIEditor_Label[8] = guiCreateLabel(0.0657,0.0741,0.365,0.1574,"400$",true,GUIEditor_Grid[7])
guiLabelSetColor(GUIEditor_Label[8],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[8],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[8],"left",false)
  GUIEditor_Grid[8] = guiCreateGridList(0.7508,0.1176,0.2246,0.3529,true,GUIEditor_Window[1])
guiGridListSetSelectionMode(GUIEditor_Grid[8],2)
  GUIEditor_Image[8] = guiCreateStaticImage(0.2336,0.1204,0.5036,0.5833,"IMG/RIFLE.png",true,GUIEditor_Grid[8])
  GUIEditor_Label[9] = guiCreateLabel(0.0657,0.0648,0.3942,0.1667,"200$",true,GUIEditor_Grid[8])
guiLabelSetColor(GUIEditor_Label[9],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[9],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[9],"left",false)
  GUIEditor_Button[9] = guiCreateButton(0.3689,0.8758,0.2525,0.0882,"Close",true,GUIEditor_Window[1])
 
 
  DEAGLE = guiCreateButton(0.0845,0.6944,0.8239,0.2315,"Deagle",true,GUIEditor_Grid[1])
  COLT = guiCreateButton(0.1056,0.6944,0.7958,0.2222,"Colt",true,GUIEditor_Grid[4])
  MP5 = guiCreateButton(0.0915,0.6944,0.7958,0.2222,"MP5",true,GUIEditor_Grid[5])
  UZI = guiCreateButton(0.0915,0.7037,0.8099,0.2222,"Micro Uzi",true,GUIEditor_Grid[2])
  M4 = guiCreateButton(0.0986,0.7037,0.8028,0.2222,"M4",true,GUIEditor_Grid[3])
  AK47 = guiCreateButton(0.1056,0.6944,0.7958,0.2315,"AK47",true,GUIEditor_Grid[6])
  SNIPER = guiCreateButton(0.1095,0.7037,0.7664,0.2315,"Sniper",true,GUIEditor_Grid[7])
  RIFLE = guiCreateButton(0.1095,0.7037,0.7737,0.2222,"Rifle",true,GUIEditor_Grid[8])
 
  CLOSE = guiCreateButton(0.3689,0.8758,0.2525,0.0882,"Close",true,GUIEditor_Window[1])
 
addEventHandler ( "onClientGUIClick", CLOSE, menu_close, false )
addEventHandler ( "onClientGUIClick", DEAGLE, gdeagle, false )
addEventHandler ( "onClientGUIClick", COLT, gColt, false )
addEventHandler ( "onClientGUIClick", UZI, gUzi, false )
addEventHandler ( "onClientGUIClick", MP5, gMp5, false )
addEventHandler ( "onClientGUIClick", M4, gM4, false )
addEventHandler ( "onClientGUIClick", AK47, gAK47, false )
addEventHandler ( "onClientGUIClick", SNIPER, gSniper, false )
addEventHandler ( "onClientGUIClick", RIFLE, gRifle, false )
 
end
end
end
addEventHandler ( "onClientMarkerHit", getRootElement(), markertarget, MarkerHit, menu_show, hitplayer )
 
function gdeagle( thePlayer )
local money = getPlayerMoney(thePlayer)
if (money > 49) then	
takePlayerMoney ( 50 )
triggerServerEvent ( "giveweapon", getLocalPlayer(), "24","10" )
else
outputChatBox("* You dont have enough money!", thePlayer )
end
end
 
function gColt( thePlayer )
local money = getPlayerMoney(thePlayer)
if (money > 49) then	
takePlayerMoney ( 50 ) 	
triggerServerEvent ( "giveweapon", getLocalPlayer(), "22","15" )
else
outputChatBox("* You dont have enough money!", thePlayer )
end
end
 
function gUzi( thePlayer )
local money = getPlayerMoney(thePlayer)
if (money > 99) then	
takePlayerMoney ( 100 )        
triggerServerEvent ( "giveweapon", getLocalPlayer(), "28","50" )
else
outputChatBox("* You dont have enough money!", thePlayer )
end
end
 
function gMp5( thePlayer )
local money = getPlayerMoney(thePlayer)
if (money > 299) then	
takePlayerMoney ( 300 )        
triggerServerEvent ( "giveweapon", getLocalPlayer(), "29","70" )
else
outputChatBox("* You dont have enough money!", thePlayer )
end
end
 
function gM4( thePlayer )
local money = getPlayerMoney(thePlayer)
if (money > 499) then	
takePlayerMoney ( 500 )          
triggerServerEvent ( "giveweapon", getLocalPlayer(), "31","100" )
else
outputChatBox("* You dont have enough money!", thePlayer )
end
end
 
function gAK47( thePlayer )
local money = getPlayerMoney(thePlayer)
if (money > 399) then
takePlayerMoney ( 400 )   
triggerServerEvent ( "giveweapon", getLocalPlayer(), "30","80" )
else
outputChatBox("* You dont have enough money!", thePlayer )
end
end
 
function gSniper( thePlayer )
local money = getPlayerMoney(thePlayer)
if (money > 399) then    
takePlayerMoney ( 400 )          
triggerServerEvent ( "giveweapon", getLocalPlayer(), "34","30" )
else
outputChatBox("* You dont have enough money!", thePlayer )
end
end
 
function gRifle( thePlayer )
local money = getPlayerMoney(thePlayer)
if (money > 199) then  
takePlayerMoney ( 200 )          
triggerServerEvent ( "giveweapon", getLocalPlayer(), "33","40" )
else
outputChatBox("* You dont have enough money!", thePlayer )
end
end
 
addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit )

Please,. i would really appreciate it if you can help me... ;)

Edited by Guest
Posted

line 27:

if getElementType(hitPlayer)=="player" and hitPlayer==getLocalPlayer() then

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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