• Script wont autorun!
    4 replies, posted
Ok so i made a script for my server, all works great except the script dosent run on the client until i update it, aka refresh the lua on the server. Canm any tell my why this is happening, and also i placed it on my server in lua/autorun [CODE]if SERVER then AddCSLuaFile() local HungerMode = false util.AddNetworkString( "HurtPlayer" ) net.Receive( "HurtPlayer", function( len, ply ) ply:SetHealth(ply:Health()-1) if(ply:Health()<=0) then ply:KillSilent() ply:SetHealth(1) end end) util.AddNetworkString("UpdateFoodDrink") function sendUpdateFood() if(HungerMode==true) then net.Start("UpdateFoodDrink") net.Broadcast() timer.Simple(1, restartUpdate) else return false end end function restartUpdate() sendUpdateFood() end if(HungerMode==true) then print("Over food started!") sendUpdateFood() end end if CLIENT then net.Receive("UpdateFoodDrink", updateHungerThirst) hook.Add("HUDPaint","UpdateOverFood",OVERFoodHUD) local HungerAmount = 75 local ThirstAmount = 75 HungerRate = 0.5 ThirstRate = 0.5 SX=ScrW() SY=ScrH() --[[Logic]]-- function updateHungerThirst() ply=LocalPlayer() if(ply:Alive()) then if(HungerAmount>0) then HungerAmount=HungerAmount-HungerRate end if(ThirstAmount>0) then ThirstAmount=ThirstAmount-ThirstRate end if(HungerAmount<0) then HungerAmount=0 end if(ThirstAmount<0) then ThirstAmount=0 end if(HungerAmount>100) then HungerAmount=100 end if(ThirstAmount>100) then ThirstAmount=100 end if(HungerAmount<=0) then net.Start("HurtPlayer") net.SendToServer() end if(ThirstAmount<=0) then net.Start("HurtPlayer") net.SendToServer() end else HungerAmount=75 ThirstAmount=75 end end --[[FONT]]-- surface.CreateFont( "OVERFHUDF", { font = "Default", size = ScreenScale(8), weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) function OVERFoodHUD() --HUD Draw code goes here --HUD Color checking HungerColor=Color(255-((HungerAmount/100)*255),0,(HungerAmount/100)*255,255) ThirstColor=Color(255-((ThirstAmount/100)*255),0,(ThirstAmount/100)*255,255) --Hunger checking local HungerBar = ((HungerAmount/100)*ScreenScale(96)) local ThirstBar = ((ThirstAmount/100)*ScreenScale(96)) --HUNGER draw.RoundedBox(0,0,0,ScreenScale(100),ScreenScale(15),Color(20,20,20,200)) --Background Box draw.RoundedBox(0,ScreenScale(2),ScreenScale(2),ScreenScale(96),ScreenScale(11),Color(0,0,0,255)) --Hunger Bar Background draw.RoundedBox(0,ScreenScale(2),ScreenScale(2),HungerBar,ScreenScale(11),HungerColor) --Hunger Bar draw.SimpleText("HUNGER","OVERFHUDF",ScreenScale(100/2),ScreenScale(15/2),Color(255,255,255),1,1) --Text --THIRST draw.RoundedBox(0,SX-ScreenScale(100),0,ScreenScale(100),ScreenScale(15),Color(20,20,20,200)) --Background Box draw.RoundedBox(0,SX-ScreenScale(98),ScreenScale(2),ScreenScale(96),ScreenScale(11),Color(0,0,0,255)) --Thirst Bar Background draw.RoundedBox(0,SX-ScreenScale(98),ScreenScale(2),ThirstBar,ScreenScale(11),ThirstColor) --Thirst Bar draw.SimpleText("THIRST","OVERFHUDF",SX-ScreenScale(100/2),ScreenScale(15/2),Color(255,255,255),1,1) --Text end end [/CODE]
Nvm
[QUOTE=Icejjfish;45656158]Nvm[/QUOTE] What?
Call you hooks after your functions have been created.
[QUOTE=scottd564;45656377]Call you hooks after your functions have been created.[/QUOTE] Ah, I Will try , Thankyou! [editline]11th August 2014[/editline] [QUOTE=darkmist;45656581]Ah, I Will try , Thankyou![/QUOTE] It worked, Thankyou so much, have been here for ages trying to work this out -.- xD!
Sorry, you need to Log In to post a reply to this thread.