
cheez3d
Members-
Posts
290 -
Joined
-
Last visited
Everything posted by cheez3d
-
I already posted a solution to your problem here but you didn't take it in consideration: viewtopic.php?f=91&t=76206
-
1) onClientRender - This event is triggered every time GTA renders a new frame. 2) onClientHUDRender - This event is triggered before GTA renders the HUD. 3) onClientPreRender - This event is triggered every time before GTA renders a new frame. 4) setTimer(function,50,0) - Executes every 50 milliseconds => 20 executions per second. 1,2 and 3 - execution speed depends directly on your framerate (if you have 10 FPS it will only get executed 10 times per second, but if you have 60 FPS it will get executed 60 times per second)
-
addEvent("onPlayerTeamChange"); local _setPlayerTeam = setPlayerTeam; setPlayerTeam = function(player,team) local PreviousTeam = getPlayerTeam(player); local Result = _setPlayerTeam(player,team); if Result then triggerEvent("onPlayerTeamChange",player,PreviousTeam,team); end; return Result; end; addEventHandler("onPlayerTeamChange",root,function(_,team) local Color = getTeamColorName(team); Color = Color and Color or {255,255,255}; local Name = getPlayerName(source); Name = ("#%.2X%.2X%.2X"):format(Color[1],Color[2],Color[3])..Name:gsub("#%x%x%x%x%x%x",""); setPlayerName(source,Name); end);
-
Lua isn't the only language I'm using.
-
addCommandHandler("t12",function() setTime(12,0); outputChatBox("Time changed to 12:00!",root); end);
-
local Vehicles = { [432] = true, [520] = true, [425] = true; }; if Vehicles[getElementModel(vehicle)] and getElementData(player,"admin") == 1 then -- your code; else outputChatBox("You are not an admin!",player); end;
-
I think using "onElementDataChange" instead of using a timer is better.
-
-- EASING EQUATIONS BY ROBERT PENNER ([url=http://www.dzone.com/snippets/robert-penner-easing-equations]http://www.dzone.com/snippets/robert-pe ... -equations[/url]) -- -- CONVERTED TO LUA BY CHEEZ -- local Easing = { Linear = function(t,b,c,d) return c*t/d+b; end, Quadratic = { In = function(t,b,c,d) t = t/d; return c*t^2+b; end, Out = function(t,b,c,d) t = t/d; return -c*t*(t-2)+b; end, InOut = function(t,b,c,d) t = t/(d/2); if t<1 then return c/2*t^2+b; end; t = t-1; return -c/2*(t*(t-2)-1)+b; end; }, Cubic = { In = function(t,b,c,d) t = t/d; return c*t^3+b; end, Out = function(t,b,c,d) t = t/d-1; return c*(t^3+1)+b; end, InOut = function(t,b,c,d) t = t/(d/2); if t<1 then return c/2*t^3+b; end; t = t-2; return c/2*(t^3+2)+b; end; }, Quartic = { In = function(t,b,c,d) t = t/d; return c*t^4+b; end, Out = function(t,b,c,d) t = t/d-1; return -c*(t^4-1)+b; end, InOut = function(t,b,c,d) t = t/(d/2); if t<1 then return c/2*t^4+b; end; t = t-2; return -c/2*(t^4-2)+b; end; }, Quintic = { In = function(t,b,c,d) t = t/d; return c*t^5+b; end, Out = function(t,b,c,d) t = t/d-1; return c*(t^5+1)+b; end, InOut = function(t,b,c,d) t = t/(d/2); if t<1 then return c/2*t^5+b; end; t = t-2; return c/2*(t^5+2)+b; end; }, Sinusoidal = { In = function(t,b,c,d) return -c*math.cos(t/d*(math.pi/2))+c+b; end, Out = function(t,b,c,d) return c*math.sin(t/d*(math.pi/2))+b; end, InOut = function(t,b,c,d) return -c/2*(math.cos(math.pi*t/d)-1)+b; end; }, Exponential = { In = function(t,b,c,d) return c*2^(10*(t/d-1))+b; end, Out = function(t,b,c,d) return c*(-2^(-10*t/d)+1)+b; end, InOut = function(t,b,c,d) t = t/(d/2); if t<1 then return c/2*2^(10*(t-1))+b; end; t = t-1; return c/2*(-2^(-10*t)+2)+b; end; }, Circular = { In = function(t,b,c,d) t = t/d; return -c*(math.sqrt(1-t^2)-1)+b; end, Out = function(t,b,c,d) t = t/d-1; return c*math.sqrt(1-t^2)+b; end, InOut = function(t,b,c,d) t = t/(d/2); if t<1 then return -c/2*(math.sqrt(1-t^2)-1)+b; end; t = t-2; return c/2*(math.sqrt(1-t^2)+1)+b; end; }, Elastic = { In = function(t,b,c,d,a,p) t,a,p = t/d-1,a and a or 0,p and p or d*0.3; local s = nil; if a<math.abs(c) then a,s = c,p/4; else s = p/(2*math.pi)*math.asin(c/a); end; return -(a*2^(10*t)*math.sin((t*d-s)*(2*math.pi)/p))+b; end, Out = function(t,b,c,d,a,p) t,a,p = t/d,a and a or 0,p and p or d*0.3; local s = nil; if a<math.abs(c) then a,s = c,p/4; else s = p/(2*math.pi)*math.asin(c/a); end; return a*2^(-10*t)*math.sin((t*d-s)*(2*math.pi)/p)+c+b; end, InOut = function(t,b,c,d,a,p) t,a,p = t/(d/2)-1,a and a or 0,p and p or d*0.3*1.5; local s = nil; if a<math.abs(c) then a,s = c,p/4; else s = p/(2*math.pi)*math.asin(c/a); end; if t+1<1 then return -0.5*(a*2^(10*t)*math.sin((t*d-s)*(2*math.pi)/p))+b; end; return a*2^(-10*t)*math.sin((t*d-s)*(2*math.pi)/p)*0.5+c+b; end; }, Back = { In = function(t,b,c,d,s) t,s = t/d,s and s or 1.7; return c*t^2*((s+1)*t-s)+b; end, Out = function(t,b,c,d,s) t,s = t/d-1,s and s or 1.7; return c*(t^2*((s+1)*t+s)+1)+b; end, InOut = function(t,b,c,d,s) t,s = t/(d/2),s and s*1.525 or 1.7*1.525; if t<1 then return c/2*(t^2*((s+1)*t-s))+b; end; t = t-2; return c/2*(t^2*((s+1)*t+s)+2)+b; end; }, Bounce = { In = function(self,t,b,c,d) return c-self.Out(d-t,0,c,d)+b; end, Out = function(t,b,c,d) t = t/d; if t<1/2.75 then return c*(7.5625*t^2)+b; elseif t<2/2.75 then t = t-1.5/2.75; return c*(7.5625*t^2+0.75)+b; elseif t<2.5/2.75 then t = t-2.25/2.75; return c*(7.5625*t^2+0.9375)+b; else t = t-2.625/2.75; return c*(7.5625*t^2+0.984375)+b; end; end, InOut = function(self,t,b,c,d) if t<d/2 then return f(t*2,0,c,d)*0.5+b; end; return self.Out(t*2-d,0,c,d)*0.5+c*0.5+b; end; }; }; Interpolate = function(a,b,t,f,d,...) if f == "Linear" then return Easing.Linear(t,a,b-a,1); elseif f == "Bounce" and d ~= "Out" then return Easing.Bounce[d](Easing.Bounce,t,a,b-a,1); end; return Easing[f][d](t,a,b-a,1,...); end; Interpolate2D = function(a,x,b,y,t,f,d,...) return Interpolate(a,x,t,f,d,...),Interpolate(b,y,t,f,d,...); end; Interpolate3D = function(a,x,b,y,c,z,t,f,d,...) return Interpolate(a,x,t,f,d,...),Interpolate(b,y,t,f,d,...),Interpolate(c,z,t,f,d,...); end; Interpolate float Interpolate ( float StartingValue , float EndingValue , float Progress , string EasingFunction , string EasingDirection [ , float EasingAmptitude , float EasingPeriod , float EasingOvershoot ] ) Interpolate2D float Interpolate2D ( float StartingX , float EndingX , float StartingY , float EndingY , float Progress , string EasingFunction , string EasingDirection [ , float EasingAmptitude , float EasingPeriod , float EasingOvershoot ] ) Interpolate3D float Interpolate3D ( float StartingX , float EndingX , float StartingY , float EndingY , float StartingZ , float EndingZ , float Progress , string EasingFunction [ , string EasingDirection , float EasingAmptitude , float EasingPeriod , float EasingOvershoot ] ) Example: print(Interpolate(50,1,0.5,"Linear")); -- => 25; Interpolate(100,35,0.75,"Elastic","InOut"); This table includes all the easing functions that exist here. I just converted the equations form ActionScript to Lua. Have fun.
-
allowRemoteTrigger: A boolean specifying whether this event can be called remotely using triggerClientEvent / triggerServerEvent or not.
-
Use ? instead of concatenation. The problem is your name which has a special character ~. You either use ? or add ' for the query to work, but I suggest ?. Read more on the wiki.
-
math.floor(distancia)
-
Or just make the team element the source of the event.
-
Reinstall MTA without deleting your resources?
-
onPlayerDamage - Canceling this event has no effect. Cancel the client-side event onClientPlayerDamage instead. + that if statement will always get executed as the getElementInterior function returns an integer (which is ≠ nil or false).
-
addEvent("onPlayerTeamChange"); local _setPlayerTeam = setPlayerTeam; setPlayerTeam = function(player,team) triggerEvent("onPlayerTeamChange",player,getPlayerTeam(player),team); return _setPlayerTeam(player,team); end; local PlayerBlips = {}; local AssigningHandler = function(player) local Team = getPlayerTeam(player); local Colors = not Team and {255,255,255} or {getTeamColor(Team)}; setPlayerNametagColor(player,Colors[1],Colors[2],Colors[3]); if PlayerBlips[player] then setBlipColor(PlayerBlips[player],Colors[1],Colors[2],Colors[3],255); elseif not PlayerBlips[player] then PlayerBlips[player] = createBlipAttachedTo(player,_,_,Colors[1],Colors[2],Colors[3]); end; end; local DestroyingHandler = function(player) if PlayerBlips[player] then destroyElement(PlayerBlips[player]); PlayerBlips[player] = nil; end; end; addEventHandler("onResourceStart",resourceRoot,function() for _,v in ipairs(getElementsByType("player") do AssigningHandler(v); end; end); addEventHandler("onPlayerSpawn",root,function() AssigningHandler(source); end); addEventHandler("onPlayerTeamChange",root,function(old_team,new_team) outputChatBox(("%s changed his team from %s to %s."):format(getPlayerName(source),getTeamName(old_team),getTeamName(new_team)),root); AssigningHandler(source); end; addEventHandler("onPlayerWasted",root,function() DestroyingHandler(source); end); addEventHandler("onPlayerQuit",root,function() DestroyingHandler(source); end); Your new event: onPlayerTeamChange (Serverside event) This event is triggered when a player team changes. This can be done using setPlayerTeam. Parameters element oldTeam, element newTeam The source of this event is the player whose team changed.
-
https://wiki.multitheftauto.com/wiki/Ge ... tsBySerial from 1.4.
-
Why don't you use XML? As for the size problem you can use fileGetSize().
-
Why? I always create my resources when my server is running, didn't had any problems with that. Just restarted the server , doesn't help at all, tried to put the folder into a .zip , same problem.. Well, that's what happens to me. Did you check if your resource is in the correct folder: server\mods\deathmatch\resources and not mods\deathmatch\resources?
-
If you created the resource when your server was already running you'll have to restart it so it can read all the resource folders again.
-
local hunters = {}; addEvent("onPlayerPickUpRacePickup",true); addEventHandler("onPlayerPickUpRacePickup",root,function(id,_type,model) if _type == "vehiclechange" and model == 425 then if hunters[source] then return; end; local account = getPlayerAccount(source); local data = { ["Hunters"] = { current = getAccountData(account,"Hunters"), add = 1; }, ["Cash"] = { current = getAccountData(account,"Cash"), add = 1000; }, ["EXP"] = { current = getAccountData(account,"EXP"), add = 5; }; }; for k,v in pairs(data) do setAccountData(account,k,(v.current and v.current or 0)+v.add); end; hunters[source] = true; end; end); addEvent("onMapStarting",true); addEventHandler("onMapStarting",root,function() for k in pairs(hunters) do k = nil; end; end); Optimised your code.
-
Of course ipairs isn't working.