• Re enter car after 5 seconds
    5 replies, posted
Hello, i'm trying to make a script when people leave the car they should get no access to enter it again, first after 5 seconds. This is how the script looks atm: [CODE]if Player:ExitVehicle() then timer.Simple( 5, function() print( "You can enter the car again in 5 seconds!") end ) end[/CODE] Anybody there can help me? - Thanks.
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4270.html[/url] [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe9ae.html[/url]
First thing - ExitVehicle() is a function to make player LEAVE vehicle. So okay. Another one Make for me please :> Np! [CODE] if SERVER then util.AddNetworkString("TAL") function NoEnterJerk( ply, ven ) if !ply:IsValid() or !ven:IsValid() or !ply:IsPlayer() then return end -- Checking for no errors ply.nej = CurTime() --Saving cur time, for check another enter to car end hook.Add("PlayerLeaveVehicle", "MakeForMePlease", NoEnterJerk) function NoEnterJerk_Check( ply, ven, role ) if !ply:IsValid() or !ven:IsValid() or !ply:IsPlayer() then return end -- Another check for no errors if ply.nej == nil then return true end if ply.nej + 5 >= CurTime() then -- This check our saved time when player left dem car. local hmtm = ply.nej + 5 - CurTime() net.Start( "TAL" ) -- sending to player message that he have to try enter that car later. net.WriteString(hmtm) net.Send(ply) return false end end hook.Add("CanPlayerEnterVehicle", "MakeForMePlease_checking", NoEnterJerk_Check) else net.Receive( "TAL", function(len) hmtm = net.ReadString() hmtm = math.Round( hmtm ) local ply = LocalPlayer() chat.AddText( Color( 0,255,0 ), ply, Color(255,255,255), ", You have to wait ", Color( 0,0,255 ), tostring(hmtm), Color(255,255,255), "•sec, before you can enter this car again" ) end) end [/CODE] Should works :) P.S. Re-codded client side. A bit nicer message :>
Ok thanks it works now ;)
Sorry forgott to pool message name :> take a look at code I rewrote it.
Sorry, you need to Log In to post a reply to this thread.