-
Posts
123 -
Joined
-
Last visited
-
Days Won
4
Everything posted by ReZurrecti0n
-
Well, remember to use local variables, nil global variables the moment it is no longer needed. Close any file you open after you're done with it. Just basic common sense really, anything at all you put into play should be put down after its use is up. Shortest possible time on server and client doesn't make much sense to me. And not familiar with the shader system, but makes sense if it may cause a frame drop depending on how complex it is. So... Only use it you feel it worth the performance it may cost...
-
local highestping=0 local playername for loop,target in ipairs(getElementsByType("player"))do if(getPlayerPing(target)>highestping)then highestping=getPlayerPing(target) playername=getPlayerName(target) end end if(playername)then print("Player "..playername.." has the highest ping ("..highestping..")") Of course you will need to modify the values to your own code for (toptime), but it could be done with something like this... If I am understanding what you're saying correctly anyway
-
I just discovered that client side events will trigger for everyone rather than just the one who triggers the event. So I need some way to check and run the code for only the one who triggered it. I'm currently having issues with one player pressing the F1 key (OnClientKey) to open a menu (custom PlayerMenu()) and everyone is getting that menu when it is only meant for the player who triggers it. How would I work this out to make it so only the triggering player gets the menu? Check using localPlayer? But what would I check against? How exactly does it all work?
-
You were kicked from the game (SD #21 s-14197522C)
ReZurrecti0n replied to treboR's question in Client
Same EXACT thing JUST happened to me as well... Will attempt a restart as recommended Update: I was able to get back in game by restarting both the server and client completely -
Marker = createMarker(1702.7998046875, -1079.2001953125, 22.89999961853, "cylinder", 2, 0, 0, 255) -- Global variable for a marker (Probably should be local) local myMarker = createMarker(1702.7998046875, -1079.2001953125, 22.89999961853, 'cylinder', 2.0, 0, 0, 255, 150) -- Locl variable for a marker function MarkerHit( Element, matchingDimension )-- The function, notice the arugments as it will be useful (Element is whatever hits the marker, a player) -- triggerClientEvent ( "onMarkerHit", getRootElement())-- This will call MarkerHit, but we already triggered MarkerHit, so this is an infinite loop outputChatBox("GG",Element)-- This is our goal... By adding the Element argument, sends the message ONLY to the player that hit the marker end -- Ends the function, easy enough addEventHandler( "onMarkerHit", getRootElement(), MarkerHit )-- Defines that MTA-SA's onMarkerHit will be the function MarkerHit, had to change this too... It will take some time, but you must learn in general how coding/scripting is done, try to understand what every line is doing. Use the MTA-SA Wiki for Events, Functions and such. Lua is the language MTA SA uses, will need to learn how the language operates too. Remember, baby steps
-
You should always try to pin point the problem by adding output messages everywhere. Or prints, but anyway, try putting a output right after the createmarker so you know that was successfully made, then another message right before TriggerClientEvent… Wait, I don't even think you need the TriggerClientEvent line, that would keep looping forever... Try commenting out that line and see if it works
-
I've already resolved the issue... However, I was unable to detect if a player was in a vehicle from the onwastedplayer event, so I don't think that code would work based on that. My trouble was that the player would teleport with the vehicle the player died in (Blowing up their own vehicle) when the vehicle was respawned. I solved it by simply stopping the vehicle from respawning until the player spawned... I appreciate your help though, I strive to learn more everyday
-
Line 2, after "cylinder" you put 2.0 instead of just 2 as the size, that might be your issue
-
I don't think you can destroy a player (I remember reading something that mentioned this a while back) The only way I know how to destroy a player is to disconnect them from the server altogether, but I could be wrong as I'm not yet that familiar with MTA-SA
-
Seems like you are trying to check a variable that doesn't exist or has been removed... But yes, MrTasty is right, we could help you more with more details
-
I had thought of that, but the custom name tag still appears at the new location which led me to believe it wasn't a camera issue, I appreciate the thought though I did resolve my issue with my previous post, now the vehicle doesn't respawn until the player does which I figured was the best fix for it
-
This is what I ended up doing: Lucky for me, the player is still detected in the vehicle on this event... function VehicleExplode() if(getVehicleOccupants(source))then toggleVehicleRespawn(source,false) setTimer(function(source)toggleVehicleRespawn(source,true);end,300000,1,source) end end
-
I'm testing by simply taking a Hydra and blowing itself up. Nothing has worked yet, can't remove the player from the vehicle, nor teleport the player either. I guess because the player is considered dead and not respawned yet. I'm thinking about targeting the vehicle instead, I can use a variable to remember what vehicle the player was in and if that vehicle respawns, cancel the event and respawn it when the player spawns... Will mess around a bit and try some work arounds, but still open to ideas if anyone has any and will report any results Is anyone familiar with resetVehicleExplosionTime and how it works, exactly? I mean if used to stop the respawn at that point, will it still respawn later?
-
Hmm, I did not even think to just remove the check, that could work... I was also thinking before I went to bed about just teleporting the player Thank you, I will give these both a shot and report back my results
-
When the player dies in a vehicle from exploding it, the vehicle will respawn and teleport the player along with it. This is because I have the player wait a minute or so before respawning and the vehicle ends up respawning first. So my first attempt was to check if the player who died was in a vehicle, but this check doesn't trigger. Then I thought I would try it the other way around and detect if a player was in the vehicle before it respawned and also failed the check. Although the player is still in the vehicle, after death, it would seem the system considers the player out of any vehicle... I have also tried to freeze the player, but still teleported with the respawning vehicle, it didn't work. So what I need to do is find a way to respawn the vehicle, but keep the player where he died, any ideas? function PlayerWasted(ammo,killer,weapon,body,stealth) if(isPedInVehicle(source))then removePedFromVehicle(source) end Also: When the vehicle does respawn and the player teleports with it, it gives another "Death Sound" as if the player was killed again. In case that info may help any...
-
[HELP] Passing an Element using a Global Variable
ReZurrecti0n replied to ReZurrecti0n's topic in Scripting
Figuring out how tables work in Lua was... Rather challenging, but did manage to figure out the very basics. For those who read this thread in hoping of an example of tables, this is what my final code turned out to be and now everything works as it was intended: local Element={} -- The simplest form of declaring a table, I decided not to get fancy with it function ClientResourceStart(resource) PED=createPed(271,-1641.0,-2248.0,31.5,0.0) -- 1st Test Ped Element[PED]={Name="Zach"} -- Giving 1st Test Ped a Name in the table setPedArmor(PED,100.0) PED=createPed(241,-1639.0,-2248.0,31.5,0.0) -- 2nd Test Ped Element[PED]={Name="Bill"} PED=createPed(158,-1643.0,-2248.0,31.5,0.0) -- 3rd Test Ped Element[PED]={Name="Mary"} setTimer(Seconds,1000,0) -- Will run the Seconds Function every second to check if player is in Range and has a LOS end function Seconds() local f1,f2,f3=getCameraMatrix() -- Another loop for players, currently only testing with Peds though for l,t in ipairs(getElementsByType("ped"))do local f4,f5,f6=getElementPosition(t) if(getDistanceBetweenPoints3D(f1,f2,f3,f4,f5,f6)<=25.0)then if(isLineOfSightClear(f4,f5,f6+2,f1,f2,f3))then local f7,f8=getScreenFromWorldPosition(f4,f5,f6+1) if(f7)and(f8)and(not Element[t]["Visible"])then -- Checks to make sure this Ped isn't already marked with "Visible" Element[t]["Visible"]=true -- Adds a new entry to the table, Visible Element[t]["ID"]="NPC" -- Adds yet another new entry to the table end elseif(Element[t]["Visible"])then -- Ped no longer in L.O.S. Element[t]["Visible"]=nil -- Removes the entry from the table Element[t]["ID"]=nil -- Removes the entry from the table end elseif(Element[t]["Visible"])then -- Ped no longer in Range Element[t]["Visible"]=nil -- Removes the entry from the table Element[t]["ID"]=nil -- Removes the entry from the table end end end function ClientRender()-- This event is constantly called, it's not wise to add anything here unless you have NO other choice... You were warned! for l,t in pairs(Element)do if(Element[l]["Visible"])then -- Checks if the element in this loop has "Visible" marked (Or exist even) DrawDXTextOnElement(l,"(#A0A0A0"..Element[l]["ID"].."#808080) #C0C0C0"..Element[l]["Name"].."",0.95,25.0,128,128,128,255,1.3) -- ^ The line above displays the Peds ID and Name above the head ^ DrawDXBoxOnElement(l,102,7,1.01,25.0,0,0,0,75)-- Black Outline Box for Health DrawDXBoxOnElement(l,100,5,1.009,25.0,64,0,0,75)-- Damage Box for Health DrawDXBoxOnElement(l,getElementHealth(l),5,1.009,25.0,255,0,0)-- Amount Box for Health if(getPedArmor(l)>0)then -- If no armor, don't bother showing an empty armor bar... DrawDXBoxOnElement(l,102,7,1.06,25.0,0,0,0,75)-- Black Outline Box for Armor DrawDXBoxOnElement(l,100,5,1.059,25.0,64,64,64,75)-- Damage Box for Armor DrawDXBoxOnElement(l,getPedArmor(l),5,1.059,25.0,255,255,255)-- Amount Box for Armor end DrawDXTextOnElement(l,"LOCAL: OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",1.12,25.0,255,255,255,255,1.3) -- Just a positioning test, this needs updating end end end Thanx again IIYama Everything in this thread has now been resolved XD -
[HELP] Passing an Element using a Global Variable
ReZurrecti0n replied to ReZurrecti0n's topic in Scripting
Since I got it to work, I've been changing the code and decided it's probably best I update what I have atm. Especially now that you have an idea of what I'm trying to do: -- Clientside Script: local PlayerVisible={} function ClientResourceStart(resource) PED=createPed(271,-1641.0,-2248.0,31.5,0.0)-- !!! TEMP !!! PED2=createPed(241,-1640.0,-2248.0,31.5,0.0)-- !!! TEMP !!! (These are the 3 Peds I'm testing with) PED3=createPed(158,-1642.0,-2248.0,31.5,0.0)-- !!! TEMP !!! setPedArmor(PED,100.0) setTimer(Seconds,1000,0) collectgarbage()-- I will be removing ALL of these found throughout my scripts shortly... end function ClientRender()-- This event is constantly called, it's not wise to add anything here unless you have to for l,t in pairs(PlayerVisible)do if(PlayerVisible[l])then -- Now Works !!! --outputChatBox("TM: #FFFFFFPoint Z!",255,150,50,true) -- The following line is what I'm now trying to figure out (Working with Tables) [Currently not working correctly] DrawDXTextOnElement(l,"(#A0A0A0"..PlayerVisible[l].id.."#808080) #C0C0C0"..PlayerVisible[l].name.."",0.95,25.0,128,128,128,255,1.3) -- ^ If the above line were to be removed, everything else would work as it should... ^ DrawDXBoxOnElement(l,102,7,1.01,25.0,0,0,0)-- Black Outline Box for Health DrawDXBoxOnElement(l,100,5,1.009,25.0,64,0,0)-- Damage Box for Health DrawDXBoxOnElement(l,getElementHealth(l),5,1.009,25.0,255,0,0)-- Amount Box for Health DrawDXBoxOnElement(l,102,7,1.06,25.0,0,0,0)-- Black Outline Box for Armor DrawDXBoxOnElement(l,100,5,1.059,25.0,64,64,64)-- Damage Box for Armor DrawDXBoxOnElement(l,getPedArmor(l),5,1.059,25.0,255,255,255)-- Amount Box for Armor DrawDXTextOnElement(l,"LOCAL: OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",1.12,25.0,255,255,255,255,1.3) end end end function Seconds() local f1,f2,f3=getCameraMatrix() -- There is another loop for type "players" here, but removed for the time being as it needs updating and only testing on Peds atm for l,t in ipairs(getElementsByType("ped"))do local f4,f5,f6=getElementPosition(t) if(getDistanceBetweenPoints3D(f1,f2,f3,f4,f5,f6)<=25.0)then if(isLineOfSightClear(f4,f5,f6+2,f1,f2,f3))then local f7,f8=getScreenFromWorldPosition(f4,f5,f6+1) if(f7)and(f8)and(not PlayerVisible[t])then PlayerVisible[t]=true -- Works, but need to make this a table of some kind PlayerVisible[t].id="NPC" -- This can't be right PlayerVisible[t].name="Bill" -- This also doesn't seem to work outputChatBox("TM: #00FF00Point A!",255,150,50,true) end elseif(PlayerVisible[t])then -- Ped no longer in L.O.S. PlayerVisible[t]=nil -- This where I was destroying the "table" end elseif(PlayerVisible[t])then -- Ped no longer in Range PlayerVisible[t]=nil -- This is also where I was destroying the "table" end end end I think what I need to do now is create a table that contains elements with various keys to store data such as: Element, "Name", "ID" and so on... Problem is, I'm not yet familiar with how to create such a table and then use it correctly. The On/Off statement was more or less for testing before going onwards So... In order for me to finish this, I have to find out how these table structures work exactly... To make the ID and NAME along with the ELEMENT itself all work -
[HELP] Passing an Element using a Global Variable
ReZurrecti0n replied to ReZurrecti0n's topic in Scripting
I'll explain what exactly I'm trying to make here in order to better understand what I want the code to do: The "Seconds" function will trigger every second to check for Players/Peds (Currently only testing Peds though) that are in range of the player and also have a L.O.S. This is because I don't want to put all these loops and checks under the ClientRender Event since it is constantly called. Anyway, the Player/Ped is then marked with PlayerVisible while/when still in range and has a L.O.S., if that Player/Ped loses either, then that is when it is removed. Although not shown in any of the code above, once a Player/Ped is marked with PlayerVisible (Point Z), DX Draws are used on the marked element to create ID, Playername, Health Bar, Armor Bar and Local Text which would come from saying anything in the local chat. So basically, this can just be thought of something like a simple nametag, if a player is close enough with a L.O.S. then it'll be seen by that player (Peds too) DrawDXTextOnElement(l,"LOCAL: OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",1.12,25.0,255,255,255,255,1.3) I have always thought that the l position in loops were always numbers(1st Var), but in this case it must be the stored element because it draws it on the Ped it found (But also keep in mind, I'm currently only testing on Peds as other players will need to be handled slightly different I'm sure) So far, it is working, next I will test on 3 different Peds all at the same time to be sure, then finally add in support for other players and whatnot Short Answer: Only players who fall out of range or lose L.O.S. lose the statement -
[HELP] Passing an Element using a Global Variable
ReZurrecti0n replied to ReZurrecti0n's topic in Scripting
I figured it out, I did need to use pairs and not ipairs, thx IIYama But I was also pointing at the t var when I needed to be pointing at the l var function ClientRender()-- This event is constantly called, it's not wise to add anything here unless you have NO other choice... You were warned! for l,t in pairs(PlayerVisible)do -- I suspect this line is the problem?! ((( I just needed to change from ipairs to pairs, thx IIYama ))) if(PlayerVisible[l])then -- If this "statement" is removed, Point Z is reached... ((( I just had to change the [t] to [l] and now it works ))) outputChatBox("TM: #FFFFFFPoint Z!",255,150,50,true)-- Not reaching this point... ((( With the noted changes, I now reach Point Z ))) end end end -
[HELP] Passing an Element using a Global Variable
ReZurrecti0n replied to ReZurrecti0n's topic in Scripting
Sorry, the information in this post was all wrong... My mistake -
[HELP] Passing an Element using a Global Variable
ReZurrecti0n replied to ReZurrecti0n's topic in Scripting
Thanks for pointing that out, did not notice there was both a "pair" and "ipair". So I did switch from: for l,t in ipairs(PlayerVisible)do to: for l,t in pairs(PlayerVisible)do But still unable to reach Point Z... I'm struggling to understand tables inside of tables and its structure, Im going to have to take some time to read over a few Lua Wiki Tuts on it again. Until the table structures click in my head. Then after that I may want to look more into: for, while, pairs and ipairs (Loop Stuff) -
I don't see why this is not working as it should, I must be overlooking a small detail somewhere... local PlayerVisible={} function ClientResourceStart(resource) setTimer(Seconds,1000,0) collectgarbage()-- Will remove ALL of these from code in the near future, will cost speed in the long run, Lua is good with recyling on its own anyway end function ClientRender()-- This event is constantly called, it's not wise to add anything here unless you have NO other choice... You were warned! for l,t in ipairs(PlayerVisible)do -- I suspect this line is the problem?! if(PlayerVisible[t])then -- If this "statement" is removed, Point Z is reached... outputChatBox("TM: #FFFFFFPoint Z!",255,150,50,true)-- Not reaching this point... end end end function Seconds() local f1,f2,f3=getCameraMatrix() for l,t in ipairs(getElementsByType("ped"))do local f4,f5,f6=getElementPosition(t) if(getDistanceBetweenPoints3D(f1,f2,f3,f4,f5,f6)<=25.0)then if(isLineOfSightClear(f4,f5,f6,f1,f2,f3+2))then local f7,f8=getScreenFromWorldPosition(f4,f5,f6+1) if(f7)and(f8)then outputChatBox("TM: #FFFFFFPoint D!",255,150,50,true)-- This point IS reached... PlayerVisible[t]=true-- Still working this... !!! --PlayerVisible[t][id]="NPC" -- Once point Z is reached, then I'll worry about this stuff --PlayerVisible[t][name]="Bill" -- Once point Z is reached, then I'll worry about this stuff end elseif(PlayerVisible[t])then-- Ped no longer in L.O.S. outputChatBox("TM: #FFFFFFPoint 1!",255,0,0,true) --PlayerVisible[t]=nil -- Removed for now in case Point 1 was triggered end elseif(PlayerVisible[t])then-- Ped no longer in Range outputChatBox("TM: #FFFFFFPoint 2!",255,0,0,true) --PlayerVisible[t]=nil -- Removed for now in case Point 2 was triggered end end collectgarbage() end addEventHandler("onClientRender",getRootElement(),ClientRender) Not great with tables yet as I am just learning them, but I don't know... Anyway, the whole idea in the above code is to reach Point Z when the PlayerVisible has anything in it Does anyone see what may be wrong in the code? Or why Point Z is not being reached anyways...? (Might be the ipairs loop under ClientRender?)
-
Absolute/Relative GUI/DX Resolution Scale Positioning
ReZurrecti0n replied to ReZurrecti0n's topic in Scripting
Yes, that's the one, TY -
Absolute/Relative GUI/DX Resolution Scale Positioning
ReZurrecti0n replied to ReZurrecti0n's topic in Scripting
(Unable to edit the last post) While browsing through the threads trying to find that function, I came across how to disable the "T" & "Y" chat inputs which now I can just make custom chat inputs and no longer need to worry about covering the "Say" or "TeamChat" text. I can also use what I just learned with positioning and scaling to properly place the new chat input under the chatbox... For those of you wondering: Just use this function to disable both chat inputs: toggleControl("chatbox",false)-- Client Side toggleControl(source,"chatbox",false)-- Server Side Just for future reference though, if you do know the name of that function that returns the chatbox values, please share it (In case someone with a similar problem finds this thread) -
Absolute/Relative GUI/DX Resolution Scale Positioning
ReZurrecti0n replied to ReZurrecti0n's topic in Scripting
Well, I got the positioning and scaling code to work as I understand more of it now which is great for displaying things such as menus, health bars, cash, etc. But not designed to precisely keep up with the chatbox's positioning/scaling (Although it does come close). So I want to try another approach... There is a function I recall from some thread that was able to return information about the chatbox, but do not remember the function, nor the thread I read it from. However, by using the x,y start values of the chatbox combined with the width and height of the chatbox. I can come up with the left/bottom position of the chatbox and then use those positions to offset the button to cover that "Say" text and in that sense, should get to the correct position everytime regardless of resolution. I'll worry about making sure the button is big enough(scaling) to cover it in every resolution because the chat does change size between resolutions. Anyway, can anyone reveal the function's name to get the chatbox's values?