Jump to content

[Important-Help]Respawn Vehicle


amirmahdi

Recommended Posts

4 hours ago, The_GTA said:

Hello amirmahdi,

if a player is assigned to a team then a hidden "team" reference is set to the requested team object. The element hierarchy is not changed. Players are not children of team elements. The setElementVisibleTo function does not change the visibility of the player because it is not a child of the team element.

Instead you can use the getPlayersInTeam function in connection with a for-loop to call the setElementVisibleTo function on all players...

...
    	setElementVisibleTo(blipes,getRootElement(),false) -- this
        for _,p in ipairs(getPlayersInTeam(getTeamFromName("Police"))) do
            setElementVisibleTo(blipes,p,true) -- This
        end
    end
...

Hope this helps!

thanks bro

Worked !

Do you know where I can find the TXD file of gta models?

Thanks for making a great software called Magic.TXD Thank you very much

  • Like 1
Link to comment
1 hour ago, amirmahdi said:

Do you know where I can find the TXD file of gta models?

Thanks for making a great software called Magic.TXD Thank you very much

You can find TXD files inside of the models folder of your GTA SA game. I recommend you to use IMG Tool version 2 or IMG Factory 1.0 to look into files that end with ".img". They contain many GTA SA game files, including TXD files.

  • Like 1
  • Thanks 1
Link to comment
33 minutes ago, The_GTA said:

You can find TXD files inside of the models folder of your GTA SA game. I recommend you to use IMG Tool version 2 or IMG Factory 1.0 to look into files that end with ".img". They contain many GTA SA game files, including TXD files.

I got it, thank you

Is it possible to make cars with police license plates respawn every 10 minutes?

I wrote it, but the problem is that it respawn all the cars on the map

for index, policecars in ipairs(getElementsByType("vehicle")) do 
    local plate = getVehiclePlateText ( policecars )
    if (plate) == "police" then
        toggleVehicleRespawn ( policecars, true )
        setVehicleIdleRespawnDelay ( policecars, 100000000 ) -- 10 Min
    end
end

 

Link to comment
2 minutes ago, amirmahdi said:

I wrote it, but the problem is that it respawn all the cars on the map

  • Are you sure that only police cars have the vehicle plate text set to "police" text? Please verify by looking at the text in-game or using scripting API.
  • Have you made a distinction between police vehicles and other vehicles in your respawn configuration? I suggest you to try disabling respawning of all other vehicles and then try enabling respawning for just the police vehicles. Maybe you will find the error in your code this way.
  • Thanks 1
Link to comment
32 minutes ago, The_GTA said:
  • Are you sure that only police cars have the vehicle plate text set to "police" text? Please verify by looking at the text in-game or using scripting API.
  • Have you made a distinction between police vehicles and other vehicles in your respawn configuration? I suggest you to try disabling respawning of all other vehicles and then try enabling respawning for just the police vehicles. Maybe you will find the error in your code this way.
  • Yes, I confirm

  • No

Link to comment
4 minutes ago, The_GTA said:

What do you mean by "No"? If you want me to help you find the problem then you have to explain more.

 

6 minutes ago, The_GTA said:

What do you mean by "No"? If you want me to help you find the problem then you have to explain more.

I mean, I did not differentiate between configurations

 

Police cars have "police" license plates, I'm sure about that

And the only problem is that in the code I sent above, I tried to make it respond only to cars that have police license plates. But unfortunately, in addition to police cars, other cars also respawn

Link to comment
8 hours ago, The_GTA said:

What do you mean by "No"? If you want me to help you find the problem then you have to explain more.

 

3 hours ago, vicisdev said:

If you are sure players will exit the car before it being drowned there could be a chance to do this.

guys

I want to do something that when "player1" hits "player2" car, give "player1"  3 Wanted

  • Note : I mean the car A car is like a police car In the code, only the car that has ID 596 should be mentioned

But I do not know how to implement it as code

Please help me with this. Thanks

Link to comment

Have you tried using an onClientVehicleDamage event handler? I am not entirely sure how to implement it as code either because I am not sure how the "theAttacker" parameter is provided to the event handler, but the idea is the following:

  • check inside of the event handler for any player's vehicle that got damaged and see if theAttacker is the vehicle of a different player who is at the same time the driver.
  • if true then use the setPlayerWantedLevel function to assign a new wanted level

The clientside skeleton could look like this:

addEventHandler("onClientVehicleDamage", root,
    function(theAttacker)
        local damVehDriver = getVehicleOccupant(source, 0)
        
        if not (damVehDriver == localPlayer) then return end
    
        if not (getElementType(theAttacker) == "vehicle") then return end
        
        local vehOwner = getVehicleOccupant(theAttacker, 0)
        
        if not (vehOwner) or (vehOwner == localPlayer) then return end
        
        -- TODO: send an event to the server to notify that vehOwner has attacked
        -- the vehicle of localPlayer. The server should decide what to do in this situation
        -- for example call the setPlayerWantedLevel function.
    end
);

Then you need a server-side custom event handler in which you receive both the player whose vehicle was damaged (A) and the driver of the attacking vehicle (B). You should perform some security checks like the player A being a cop and B not being a cop, etc. Then you should call the setPlayerWantedLevel function on B if the condition is met.

  • Thanks 1
Link to comment
  • 3 months later...
On 17/12/2021 at 00:28, The_GTA said:

Have you tried using an onClientVehicleDamage event handler? I am not entirely sure how to implement it as code either because I am not sure how the "theAttacker" parameter is provided to the event handler, but the idea is the following:

  • check inside of the event handler for any player's vehicle that got damaged and see if theAttacker is the vehicle of a different player who is at the same time the driver.
  • if true then use the setPlayerWantedLevel function to assign a new wanted level

The clientside skeleton could look like this:

addEventHandler("onClientVehicleDamage", root,
    function(theAttacker)
        local damVehDriver = getVehicleOccupant(source, 0)
        
        if not (damVehDriver == localPlayer) then return end
    
        if not (getElementType(theAttacker) == "vehicle") then return end
        
        local vehOwner = getVehicleOccupant(theAttacker, 0)
        
        if not (vehOwner) or (vehOwner == localPlayer) then return end
        
        -- TODO: send an event to the server to notify that vehOwner has attacked
        -- the vehicle of localPlayer. The server should decide what to do in this situation
        -- for example call the setPlayerWantedLevel function.
    end
);

Then you need a server-side custom event handler in which you receive both the player whose vehicle was damaged (A) and the driver of the attacking vehicle (B). You should perform some security checks like the player A being a cop and B not being a cop, etc. Then you should call the setPlayerWantedLevel function on B if the condition is met.

Hello brother, I have a question, do you think it would be better if I use zip instead of folder? Of course, I know I have trouble editing the code, but it does not matter, if we do not consider this problem, zip is a better choice?

Link to comment
On 28/03/2022 at 17:25, amirmahdi said:

Hello brother, I have a question, do you think it would be better if I use zip instead of folder? Of course, I know I have trouble editing the code, but it does not matter, if we do not consider this problem, zip is a better choice?

You should use folder as MTA when run the scripts it unzips the folder in to resource-cache folder so its does not matter. 

  • Like 1
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...