Announcement

Collapse
No announcement yet.

SetVehicleLicensePlate problem

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    SetVehicleLicensePlate problem

    Hi,

    i'm a LUA beginner and i'm trying to when i type /test the VehicleLicensePlate change to "T E S T" but it's working only one time when i restart the server, if i restart the script it's not working :

    client.lua:
    PHP Code:
    AddRemoteEvent("Test", function(vehicle)
        
    vehicle GetStreamedVehicles(player)
        for 
    kv in pairs(vehicle) do
            
    CallRemoteEvent("SetLicensePlate"vehicle)
        
    end
    end


    server.lua:
    PHP Code:
    AddRemoteEvent("SetLicensePlate", function(vehicle)
        
    SetVehicleLicensePlate(vehicle"T E S T")
    end)
    AddCommand("test", function(player)
        
    CallRemoteEvent(player"Test")
    end
    Last edited by MisTerioN; 01-01-2020, 07:23 PM.

    #2
    Hello!

    What are you trying to do exactly, because your description isn't fluent as well. So could you describe better your problem .

    Yanis
    “Logic will get you from A to Z; imagination will get you everywhere.”
    - Albert Einstein

    Comment


      #3
      UPDATE:

      dimmiesTV found the problem and solved it i just wanted to set to the streamed vehicles the plate "T E S T" as an exercise but GetStreamedVehicles() is apparently not working for me

      so he fixed it by doing this :

      PHP Code:
      function test(player)
          
      vehs GetAllVehicles()
          for 
      k,v in pairs(vehs) do
              
      SetVehicleLicensePlate(v"T E S T")
          
      end
      end

      AddCommand
      ("test"test

      GetAllVehicles() is working better


      i can't modify or delete my post so i just put the lamp

      Comment


        #4
        GetStreamedVehicles is working but your code was wrong. Your variable naming was bad what lead you into making a mistake. You set "vehicle" to a list of vehicles, then iterate over it, mapping the key to "k" and the value to "v". Then you are calling the remote event with the list "vehicle" instead of the actual vehicle "v".

        Its better to do it on the serverside like you did and then add an if-condition that checks for each vehicle "v" if the vehicle is streamed in for the player (IsVehicleStreamedIn).

        Comment

        Working...
        X