Jump to content

VIP panel


Recommended Posts

Hallo allemaal,

Ik heb een VIP panel voor mijn server die in goede staat werkt.

Alleen heb ik het probleem dat de button om een auto te spawnen meerdere keren gebruikt kan worden.

Dit houd in dat er meedere auto gespawnd kunnen worden.

Zou iemand mij deze scripts kunnen aanpassen zodat de auto eerst verwijdert worden en dan pas een nieuwe gespawnt zal worden?

Cient:

GUIEditor = { 
    button = {}, 
    staticimage = {}, 
    window = {}, 
} 
  
function OpenVIPwindow () 
GUIEditor.window[1] = guiCreateWindow(445, 240, 300, 182, "(SARS:RPG) VIP panel", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
  
GUIEditor.button[1] = guiCreateButton(5, 20, 136, 30, "Spawn jetpack", false, GUIEditor.window[1]) 
GUIEditor.button[2] = guiCreateButton(5, 60, 136, 30, "Spawn armor", false, GUIEditor.window[1]) 
GUIEditor.button[3] = guiCreateButton(150, 20, 136, 30, "Spawn VIP skin", false, GUIEditor.window[1]) 
GUIEditor.button[4] = guiCreateButton(150, 60, 136, 30, "Spawn VIP weapons", false, GUIEditor.window[1]) 
GUIEditor.button[5] = guiCreateButton(5, 140, 278, 30, "Close", false, GUIEditor.window[1]) 
GUIEditor.button[6] = guiCreateButton(5, 100, 278, 30, "Spawn VIP vehicle", false, GUIEditor.window[1]) 
showCursor ( true ) 
  
function JetpackGive () 
triggerServerEvent ( "onJetpack",localPlayer)  
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[1], JetpackGive, false ) 
  
function ArmorGIVE () 
triggerServerEvent ( "onArmor",localPlayer)  
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[2], ArmorGIVE, false ) 
  
function VipSKINGive () 
triggerServerEvent ( "onSkinVip",localPlayer)  
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[3], VipSKINGive, false ) 
  
function WeaponsVIP () 
triggerServerEvent ( "onWeaponGive",localPlayer)  
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[4], WeaponsVIP, false ) 
  
function VehicleCAR () 
triggerServerEvent ( "vehiclecar",localPlayer)  
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[6], VehicleCAR, false ) 
  
function Window2Load () 
if not GUIEditor.window[2] then 
triggerEvent ("newWindow",source) 
end 
if guiGetVisible ( GUIEditor.window[2],true ) then 
guiSetVisible ( GUIEditor.window[2],false) 
else 
guiSetVisible ( GUIEditor.window[2],true) 
end 
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[7], Window2Load, false ) 
  
function CloseWindowSet () 
if guiGetVisible (GUIEditor.window[1] ) == true then 
guiSetVisible (GUIEditor.window[1],false) 
showCursor ( false ) 
else 
guiSetVisible (GUIEditor.window[1],true) 
showCursor ( true ) 
end 
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[5], CloseWindowSet, false ) 
  
function CloseBindKey () 
windowVisible = guiGetVisible ( GUIEditor.window[1] ) 
  if ( windowVisible == true ) then 
  guiSetVisible ( GUIEditor.window[1] ,false) 
  showCursor (false) 
  guiSetVisible ( GUIEditor.window[2],false) 
  else 
  guiSetVisible ( GUIEditor.window[1] ,true) 
  showCursor (true) 
  guiSetVisible ( GUIEditor.window[2],true) 
  end 
end 
bindKey ( "F7", "down", CloseBindKey ) 
  
end 
addEvent( "GUIVIP", true ) 
addEventHandler( "GUIVIP", getRootElement(), OpenVIPwindow ) 

server:

function VIPMENUTRIGGER ( thePlayer , commandName ) 
   local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then  
   triggerClientEvent ( thePlayer, "GUIVIP", thePlayer) 
   else 
   outputChatBox ( "",thePlayer) 
   end 
 end 
addCommandHandler ( "vip", VIPMENUTRIGGER ) 
  
function JetpackGive  ( ) 
   local accName = getAccountName ( getPlayerAccount ( source ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then  
   local hasJetPack = doesPedHaveJetPack ( source ) 
   outputChatBox ("",source,255,255,0,false) 
if ( hasJetPack ) then   
removePedJetPack ( source )   
else 
givePedJetPack ( source ) 
end 
end 
  end 
addEvent( "onJetpack", true ) 
addEventHandler( "onJetpack", getRootElement(), JetpackGive ) 
  
function OnPedGiveArmor ( ) 
   local accName = getAccountName ( getPlayerAccount ( source ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then  
setPedArmor (source,100) 
outputChatBox("",source,255,255,0,false) 
   end 
end 
addEvent( "onArmor", true ) 
addEventHandler( "onArmor", getRootElement(),OnPedGiveArmor ) 
  
function SetSkinSERVER ( ) 
   local accName = getAccountName ( getPlayerAccount ( source ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then  
setPedSkin (source,260) 
outputChatBox("",source,255,255,0,false) 
   end 
end 
addEvent( "onSkinVip", true ) 
addEventHandler( "onSkinVip", getRootElement(),SetSkinSERVER  ) 
  
function vehiclecar ( ) 
   local accName = getAccountName ( getPlayerAccount ( source ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then  
   x,y,z = getElementPosition ( source ) 
   createVehicle ( 415, x + 3, y, z + 1 ) 
   outputChatBox("",source,255,255,0,false) 
   end 
end 
addEvent( "vehiclecar", true ) 
addEventHandler( "vehiclecar", getRootElement(),vehiclecar ) 
  
  
function GiveWeaponToVIP  ( ) 
   local accName = getAccountName ( getPlayerAccount ( source ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then  
giveWeapon (source,8,1) 
giveWeapon (source,24,21) 
giveWeapon (source,29,150) 
outputChatBox("",source,255,255,0,false) 
   end 
end 
addEvent( "onWeaponGive", true ) 
addEventHandler( "onWeaponGive", getRootElement(),GiveWeaponToVIP ) 
  
function destroyIt() 
    if (isElement(vehicle[source])) then 
        destroyElement(vehicle[source]) 
    end 
end 
addEventHandler("onPlayerWasted", root, destroyIt) 
addEventHandler("onPlayerLogout", root, destroyIt) 
addEventHandler("onPlayerQuit", root, destroyIt) 

Groetjes,

Wesley

Link to comment
  • Moderators
  
-- zet boven aan het script. 
local vehicleOwners = {} 
  
  
-- opslaan 
vehicleOwners[player] = vehicle 
  
--verkrijgen 
local vehicle = vehicleOwners[player]  
  
  
-- controleren en verweideren 
if isElement(vehicle) then  
      destroyElement(vehicle)  
end 
  
  
-- automatisch schoonmaken wanneer iemand weg gaat. 
addEventHandler("onPlayerQuit",root, 
function () 
      local vehicle = vehicleOwners[source] 
      if  vehicle then 
            if isElement(vehicle) then 
                  destroyElement(vehicle) 
            end 
            vehicleOwners[source] = nil 
      end 
end) 
  

Meer heb je eigenlijk niet nodig. Je moet wel alle "variables" de goede definities geven.

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