[RELEASE] Unrack and Rack simple reply script


#49

If you tried changing the code i wont help you. I gave all possible directions. Aswell as try to install it again


#50

RegisterCommand(“unrack”, function(source, args, rawCommand)

local vehicle = GetVehiclePedIsIn(GetPlayerPed(1), true)
local class = GetVehicleClass(vehicle)

if( class == 18) then

  GiveWeaponToPed(GetPlayerPed(1), "WEAPON_CARBINERIFLE", 1000, true, true)

end
end)

RegisterCommand(“rack”, function(source, args, rawCommand)

local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), true)
local class = GetVehicleClass(vehicle)

if( class == 18) then

  GiveWeaponToPed(GetPlayerPed(-1), "WEAPON_CARBINERIFLE", 1000, false, false)

end
end)

@Woopi


#51

Show me the error your getting please


#52

@Lukepollie

Error running call reference function for resource rack_unrack: citizen:/scripting/lua/scheduler.lua:379: server.lua:3: attempt to call a nil value (global ‘GetVehiclePedIsIn’)
stack traceback:
server.lua:3: in upvalue ‘ref’
citizen:/scripting/lua/scheduler.lua:365: in function citizen:/scripting/lua/scheduler.lua:364
[C]: in function ‘xpcall’
citizen:/scripting/lua/scheduler.lua:364: in function citizen:/scripting/lua/scheduler.lua:363
stack traceback:
[C]: in function ‘error’
citizen:/scriptinError running call reference function for resource rack_unrack: citizen:/scripting/lua/scheduler.lua:379: server.lua:3: attempt to call a nil value (global ‘GetVehiclePedIsIn’)
stack traceback:
server.lua:3: in upvalue ‘ref’
citizen:/scripting/lua/scheduler.lua:365: in function citizen:/scripting/lua/scheduler.lua:364
[C]: in function ‘xpcall’
citizen:/scripting/lua/scheduler.lua:364: in function citizen:/scripting/lua/scheduler.lua:363
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:379: in function citizen:/scripting/lua/scheduler.lua:348g/lua/scheduler.lua:379: in function citizen:/scripting/lua/scheduler.lua:348


#53

Okay, blame on @Woopi for changing the script without testing it. Not my issue anymore


#54

That looks to me you are using the GetVehiclePedIsIn server sided, you need to use it client sided.


#55

Also, I really wouldn’t bother using the class, if you wanna restrict just base it off the players skin or identifier through a function and a table.

If you wanna add this into a proximity try this

Client

RegisterNetEvent('proxUnrack')
AddEventHandler('proxUnrack', function(id, name)
  local ID = PlayerId()
  local plyID = GetPlayerFromServerId(id)
    if plyID == ID then
      TriggerEvent('chatMessage', "", {255, 255, 255}, " ^*".. name .. " Unracks ^1M4 ".." ")
    elseif GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(ID)), GetEntityCoords(GetPlayerPed(plyID)), true) < 49.999 then
      TriggerEvent('chatMessage', "", {255, 255, 255}, " ^*".. name .. " Unracks ^1M4 ".." ")
    end
end)

RegisterNetEvent('proxRack')
AddEventHandler('proxRack', function(id, name)
  local ID = PlayerId()
  local plyID = GetPlayerFromServerId(id)
    if plyID == ID then
      TriggerEvent('chatMessage', "", {255, 255, 255}, " ^*".. name .. " Racks ^1M4 ".." ")
    elseif GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(ID)), GetEntityCoords(GetPlayerPed(plyID)), true) < 49.999 then
      TriggerEvent('chatMessage', "", {255, 255, 255}, " ^*".. name .. " Racks ^1M4 ".." ")
    end
end)

Server

RegisterCommand('unrack', function(source, args, user)
    local name = GetPlayerName(source)
    TriggerClientEvent("proxUnrack", -1, source, name)
end, false)

RegisterCommand('rack', function(source, args, user)
    local name = GetPlayerName(source)
    TriggerClientEvent("proxRack", -1, source, name)
end, false)

Untested but just an idea.


#56

Appriciate it
Thank you
this will help alot


#57

BUMB

The Script now will give you the weapons + message is server side.
This will be the last version.

(not gonna do this for the civ version cause that makes no sense, just change the text message)