
adithegman
Members-
Posts
32 -
Joined
-
Last visited
Everything posted by adithegman
-
Found error, fixed.
-
I'm trying to develop the spectating system and ran into this error: When a player dies and the startSpectate event is called from server, there is an error at the setCameraTarget function: bad argument @ 'setCameraTarget' [ Expected Vector 3 at argument 1, got nil] I checked the updatePlayers() function to see whether the players table was formed correctly or not and it is. Thanks for helping!? Client script: local players = {} local index = 1 local function updatePlayers() players = {} local candidates = getElementsByType("player") for k, v in ipairs(candidates) do if getElementData(v, "game.status") == "playing" then table.insert(players, v) end end end local function spectatePrevious() if index == 1 then index = #players else index = index - 1 end setCameraTarget(players[i]) end local function spectateNext() if index == #players then index = 1 else index = index + 1 end setCameraTarget(players[i]) end local function startSpectateHandler() setElementData(localPlayer, "game.status", "spectating") updatePlayers() index = 1 bindKey("arrow_l", "down", spectatePrevious) bindKey("arrow_r", "down", spectateNext) t = players[i] setCameraTarget(t) --- This is the line warning the error occurs end local function stopSpectateHandler() unbindKey("arrow_l", "down", spectatePrevious) unbindKey("arrow_r", "down", spectateNext) setCameraTarget(localPlayer) end addEventHandler("onClientResourceStart", resourceRoot, updatePlayers) addEventHandler("onPlayerJoin", root, updatePlayers) addEventHandler("onPlayerQuit", root, updatePlayers) addEvent("startSpectate", true) addEventHandler("startSpectate", localPlayer, startSpectateHandler) addEvent("stopSpectate", true) addEventHandler("stopSpectate", localPlayer, startSpectateHandler)
-
Hey guys, need some help with my code, the script works, but it spams me this warning: Code: function onRender( ) if isCursorShowing( ) then vehicles = getElementsByType( "vehicle" ) local px, py, pz = getElementPosition( localPlayer ) for key, vehicle in ipairs(vehicles) do local vx, vy, vz = getElementPosition( vehicle ) local distance = getDistanceBetweenPoints3D ( vx,vy,vz,px,py,pz ) if distance < 30 then local w, h = guiGetScreenSize () local scalex, scaley = w/1920/distance, h/1080/distance local x, y = getScreenFromWorldPosition ( vx, vy, vz + 1 ) dxDrawImage ( x, y, 200 * scalex, 200 * scaley, "steering_wheel.png" ) end end end end addEventHandler( "onClientRender", getRootElement(), onRender ) Update! After a while I got bored and decided to take a ride around LS for some time, and I noticed that when I'm around just one car, it doesn't show me the warning. So i went to the wiki and found out that getScreenFromWorldPosition returns false if the camera does not see the object. Modified the code and now it works perfectly! local x, y = getScreenFromWorldPosition ( vx, vy, vz + 1 ) if x ~= false then dxDrawImage ( x, y, 200 * scalex * 4, 200 * scaley * 4, "steering_wheel.png" ) end
-
Thanks man, don't know how I missed that
-
I've tried to make a script that tells you what are you aiming at. For ex, it tells you if you're aiming at a player or a vehicle. But for whatever reason, it doesn't work... The script runs just fine, no warnings/errors. Thanks for the help. function checkAiming( ) if isPedAiming ( getLocalPlayer() ) then local w, h = guiGetScreenSize () local elementType = getElementType ( getPedTarget ( getLocalPlayer ( ) ) ) dxDrawText ( "You are aiming at a(n) " .. elementType .. " now", w/2, h/4) end end addEventHandler( "onPlayerRender", getRootElement(), checkAiming )
-
Is there any possible way that when the player is in an interior, for example CJ's house, to make the windows transparent and the player to be able to see outside when he looks through them?
-
Thanks for the example man! I think I got the idea... And BTW, I don't really need a timer for every vehicle, It is something close to that but a bit more complicated to explain so I just asked that question hoping that it will implicitly answer my ohter unknowings and fortunately it did. Thanks for the help!
-
Hey! I just started scripting in LUA and I need some help... I have a very good knowledge of the C languages (mainly C++) but I'm having trouble understanding a few things. What I want to do is create a timer (x = setTimer(...) ) for every vehicle on the server... and I have no idea how to do it. I know it must be tied to tables, I tried using tables but I failed... I only just started on LUA today so I'm a pretty big noob NOTE: This account is not MINE so disregard my other posts
-
not working... working just when start the resource
-
i made another one from scratch so create a new lua file named "server" without quotes witch containes this code: local Criminal = createTeam ( "Criminal", 155, 0, 0 ) function putPlayerInTeam ( player ) if ( isElement ( player ) ) then if ( getPlayerTeam ( player ) == getTeamFromName ( "Criminal" )) then outputChatBox("* You Are Already On The 'Criminal' Team!",player,255,0,0) return end setPlayerTeam ( player , Criminal ) outputChatBox("* You Have Been Joined Into The 'Criminal' Team! ",player,155,0,0) end end addCommandHandler ( "criminal", putPlayerInTeam ) and don't forget to create "meta.xml" file witch contains: <meta> <script src="server.lua" type="server" /> </meta> note: mta.xml must be in the same folder with server.lua hope it helps
-
hello guys, i'm tryng to make a script that every five minutes it cleares the chat, but... it doesn't work pls help This is client-side local cleared = 0 function timer() if ( cleared == 0 ) then setTimer ( clearChat, 60000*5, 1 ) cleared = 1 end end function clearChat() done=0 cleared = 0 while done<=200 do outputChatBox("",0,0,0,false) done = done+1 end setTimer ( timer, 1, 1 ) end addEventHandler ( "onClientResourceStart", getRootElement, timer )
-
to be honest, my friend asked me to ask the community because on his server it doesn't work, so i don't know if he has permision....
-
hi guys i have this panel and the maps aren't loading, i hope you guys can find the problem
-
hello guys, i have a problem with the anti-spam and hope you guys can solve it it outputChatBox well cuz' i see for ex Adithegman has been muted... but it doesn't mute me for 1 min, i can still speak note: this is server-side antiSpam = {} function antiChatSpam() if isTimer(antiSpam[source]) then cancelEvent() outputChatBox("#ffffff"..getPlayerName(source).." has been #ff0000muted #fffffffor for 60 seconds, reason: #ff0000spam", getRootElement(), 255, 255, 0,true) setPlayerMuted ( source, true ) setTimer ( autoUnmute, 60000, 1, source) else antiSpam[source] = setTimer(function(source) antiSpam[source] = nil end, 1000, 1, source) end end addEventHandler("onPlayerChat", root, antiChatSpam) local commandSpam = {} function preventCommandSpam( command ) if command == "say" then if (not commandSpam[source]) then commandSpam[source] = 1 elseif (commandSpam[source] == 5) then cancelEvent() outputChatBox("#ffffff"..getPlayerName(source).." has been #ff0000muted #fffffffor for 60 seconds, reason: #ff0000spam!", getRootElement(), 255, 255, 0,true) setPlayerMuted( source, true ) setTimer ( autoUnmute, 60000, 1, source) else commandSpam[source] = commandSpam[source] + 1 end end end addEventHandler("onPlayerCommand", root, preventCommandSpam) setTimer(function() commandSpam = {} end, 1000, 0) function autoUnmute ( source ) setPlayerMuted ( source, false ) end
-
this shall work momentally but i need a table because there are more clans.... but thx for trying
-
i'm trying to make a script so when you connect it automatically puts you in the clan if you have for ex KekZ| in front of your nick
-
hi all, i made this clan script for my friend's server and it's not working I hope you guys can find the problem and help me note: it is Server-Side clans = { createTeam ( "KekZ|", 10, 200, 0 ) } function clan( source ) name = getPlayerName ( source ) if (string.find ( name, getTeamName ( clans )" )) then setPlayerTeam ( source, clans ) end end addEventHandler ( "onPlayerJoin", getRootElement(), clan)
-
ok i know now how to do it thx!
-
Thx for help, but if there are more teams how must i do?
-
hello everybody! can you pls help me? i want to create a script for my friend's server for clans so when you connect it checks if you have a clan name in your nametag for ex: |TG|adithegman and then it puts you in the team with setPlayerTeam but i don't know how to get the part of the name |TG|?
-
o thx now it works! thx man... credit is going to you!
-
no man... /lw doesn't work...