Jump to content

Flying cars with STAFF team


Annas

Recommended Posts

i try to make a simple script (Flying cars , only with team named "Staff")

CLIENT SIDE

  
cst = false 
function fly(player) 
   if isPlayerInTeam(player, "Staff") then 
      if (cst == false) then 
      cst = true 
      setWorldSpecialPropertyEnabled("aircars", true) 
      triggerServerEvent("onFly", getLocalPlayer()) 
      else 
      cst = false 
      setWorldSpecialPropertyEnabled("aircars", false) 
      triggerServerEvent("offFly", getLocalPlayer()) 
      end 
end 
addCommandHandler("fly", fly) 

SERVER SIDE

function on() 
outputChatBox("Flying Cars is now Enabled", source, 255, 255, 255, true) 
end 
addEvent("onFly", true) 
addEventHandler("onFly", getRootElement(), on) 
  
function off(thePlayer) 
outputChatBox("Flying Cars is now Disabled", source, 255, 255, 255, true) 
end 
addEvent("offFly", true) 
addEventHandler("offFly", getRootElement(), off) 

this resource taked from the Community.mtasa , so i edit it + try to add some more things ..

Link to comment

SERVER:

cst = false 
function fly(player) 
   if isPlayerInTeam(player, "Staff") then 
      if (cst == false) then 
        cst = true 
        triggerClientEvent(player,"onFly", player) 
        outputChatBox("Flying Cars is now Enabled", player, 255, 255, 255, true) 
        else 
        cst = false 
        triggerClientEvent(player,"offFly", player) 
        outputChatBox("Flying Cars is now Disabled", player, 255, 255, 255, true)        
        end 
    end 
end 
addCommandHandler("fly", fly) 
  
function isPlayerInTeam(player, team) 
    assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") 
    assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") 
    return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) 
end 

CLIENT:

addEvent("onFly", true) 
addEvent("offFly", true) 
  
function flyON() 
    setWorldSpecialPropertyEnabled("aircars", true) 
end 
function flyOFF() 
    setWorldSpecialPropertyEnabled("aircars", false) 
end 
  
addEventHandler("onFly", getRootElement(), flyON) 
addEventHandler("onFly", getRootElement(), flyOFF) 

Edited by Guest
Link to comment

it can be all Client side i don't know why u are trying to use tiggerServerEvent()

local cst = false 
  
function flyCar() 
   if (getTeamName(getPlayerTeam(localPlayer)) == "Staff") then  
      if cst then 
      setWorldSpecialPropertyEnabled("aircars", false) 
        outputChatBox("Flying Cars is now Disabled",255, 255, 255) 
      cst = false 
      else 
      setWorldSpecialPropertyEnabled("aircars", true) 
      outputChatBox("Flying Cars is now Enabled",255, 255, 255) 
      cst = true 
    end 
end 
end  
addCommandHandler("fly", flyCar) 

Link to comment

not work :(

---------------

trying WALID LUA ..

---------------

Working thx @Walid , but can you make it if i press JUMP boutom it will start/stop the flying ? btw thx ..

---------------

i add it with my self :D , ./lock

Link to comment
not work :(

---------------

trying WALID LUA ..

---------------

Working thx @Walid , but can you make it if i press JUMP boutom it will start/stop the flying ? btw thx ..

remove addCommandHandler and use:

bindKey("lshift", "down", flyCar) 

Link to comment
not work :(

---------------

trying WALID LUA ..

---------------

Working thx @Walid , but can you make it if i press JUMP boutom it will start/stop the flying ? btw thx ..

---------------

i add it with my self :D , ./lock

What ??? try this it's client side

addCommandHandler ("fly", 
function () 
    if (getTeamName(getPlayerTeam(localPlayer)) == "Staff") then 
        if not flyEnabled then 
            setWorldSpecialPropertyEnabled ( "aircars", true ) 
            outputChatBox("Flying Cars is now Enabled",255, 255, 255) 
            flyEnabled = true 
        else 
            outputChatBox("Flying Cars is now Disabled",255, 255, 255) 
            setWorldSpecialPropertyEnabled ( "aircars", false ) 
            flyEnabled = false 
        end 
    end 
end 
) 

Working thx @Walid , but can you make it if i press JUMP boutom it will start/stop the flying ? btw thx ..

np

Link to comment
guys still have a problem ..

when im not in a vehicle it showed

Flying Cars is now Enabled

Flying Cars is now Disabled

i wanna it only with vehicle can let it showed ..

use

isPedInVehicle () 

addCommandHandler ("fly", 
function () 
    if (getTeamName(getPlayerTeam(localPlayer)) == "Staff") then 
     if isPedInVehicle (localPlayer) then  
        if not flyEnabled then 
            setWorldSpecialPropertyEnabled ( "aircars", true ) 
            outputChatBox("Flying Cars is now Enabled",255, 255, 255) 
            flyEnabled = true 
        else 
            outputChatBox("Flying Cars is now Disabled",255, 255, 255) 
            setWorldSpecialPropertyEnabled ( "aircars", false ) 
            flyEnabled = false 
        end 
    end 
end 
end  
) 

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