Jump to content

mrjackniko

Members
  • Posts

    8
  • Joined

  • Last visited

mrjackniko's Achievements

Newbie

Newbie (4/54)

0

Reputation

  1. Hi, so i have a table which represents a custom object. It has several member variables and member functions. So, i want to tie a function to an event. Now, i could either tie an event handler to each custom object instance so i would have the same amount of handlers and instances and the source of that event handler would be that instance or i could create a table "instances" where i can use these custom objects as keys and the value would be either "true" if it exists or "nil" if it doesn't so i would have constant time access and would use a event handler which calls a function that accesses that table and checks if that object exists or not. Which method is more efficient? I am thinking that the first method might be slightly faster since the event is triggered only for a specific object but at the cost of memory since there is an event handler for each object. The second might be a bit slower since the event is triggered for each object but then again it does not loop through the table, it accesses it instantly. Or am i wrong?
  2. Ok so i figured it out. In a map specific file called "mapEditorScriptingExtension_s.lua" there is a table called LOD_MAP which consists of object - LOD_model pairs. It automatically generates pairs, but for some reason it does not generate all the pairs you use in a map. So the fix is simple, just write missing pairs.
  3. Hi, so i toggled "Use LODs" in map settings and some editor created objects use LODs while others don't even though they have LOD. For example, a baseball pitch in LV, the grass object changes into LOD while those seats on the stadium do not even though they have LOD since they do change in the original map. Why is that?
  4. Hello, everyone! So i've been doing some scripts in my free time. So i am doing some testing with some ideas and currently i am writing a vehicle pickup system (some kind of vehicle deathmatch). I wanted to create custom pickup elements with few additional variables and different animation. Since models cannot be attached to custom elements, i created new object and set it as a child. I did this all server-side and passed it to client-side file because i wanted it animated client-side using onClientRender. Here is server-side file: pickups = {} local BOX_MDL = 1271 local respawnTime = 30000 function createVehiclePickup(pickupType, x, y, z) local pickup = { element = nil, model = nil, isActive = true, rot_angle = 0, startZ = z } if (pickupType == 1) then pickup.element = createElement("vdm_pickup", "weapon_pickup") pickup.model = createObject(BOX_MDL, x, y, z) setElementParent(pickup.model, pickup.element) setElementCollisionsEnabled(pickup.model, false) elseif (pickupType == 2) then pickup.element = createElement("vdm_pickup", "powerup_pickup") end table.insert(pickups, pickup) end function getPickupList() return pickups end addEventHandler("onPlayerChat", getRootElement(), function(message) if (message == "test") then destroyElement(pickups[1].element) table.remove(pickups, 1) elseif (message == "test2") then setElementModel(pickups[1].model, 1272) end end) And here is client-side file: cl_pickups = {} function clientUpdatePickupListHandler(list) local len = #list table.insert(cl_pickups, list[len]) end addEvent("clientUpdatePickupList", true) addEventHandler("clientUpdatePickupList", getResourceRootElement(), clientUpdatePickupListHandler) local delta_phi = 6 addEventHandler("onClientRender", getRootElement(), function() if (#cl_pickups == 0) then return false else for i = 1, #cl_pickups do if (cl_pickups[i].isActive) then if (cl_pickups[i].rot_angle == 360) then cl_pickups[i].rot_angle = 0 end local x, y, z = getElementPosition(cl_pickups[i].model) local rx, ry, rz = getElementRotation(cl_pickups[i].model) setElementPosition(cl_pickups[i].model, x, y, cl_pickups[i].startZ + 0.2 * math.sin(math.rad(cl_pickups[i].rot_angle))) setElementRotation(cl_pickups[i].model, rx, 5 * math.sin(math.rad(cl_pickups[i].rot_angle)), cl_pickups[i].rot_angle) cl_pickups[i].rot_angle = cl_pickups[i].rot_angle + delta_phi end end end end) addEventHandler("onClientCharacter", getRootElement(), function(char) if (char == 'o') then setElementModel(cl_pickups[1].model, 1270) end end) Tested it and works as it should. I have few questions: 1. I am using tables to pass data. I know i can also use setElementData. Which method is better in this case? 2. I already mentioned it is animated using onClientRender. Is this good approach? I know i could use timers on server and animate it that way and i understand animations would be synced for all clients but animation will lag as the server lags. Client-side approach is independent on server connection, but it is not synced between clients. However, i think that it does not matter since animation is purely aesthetic. 3. I added onPlayerChat and onClientCharacter as a debug functions. When i type "test2", since it is server-side function, model is changed for all clients and it does. When i press 'o', since it is client-side function, it changes model for that particular player only. So if i understand right, am i passing reference to elements and objects when i pass tables from server to clients? Thanks everyone and i apologise for a longer post!
  5. Hello everyone. I am making a map and i noticed that after a set amount of cars are put in place, in my case a parking lot, furthest ones begin to disappear. I guess there is a limit of how many cars can be rendered on screen. Is there a way to increase this limit?
  6. Ok, so I tried and it doesn't work.I think the problem is somewhere with ( vTeamID == TeamOne) etc. I believe something else should be written. When I test it, I get the message in chat "First part works", but not "Second part works". I assume that means that everything works until the part with (vTeam == TeamOne) then...
  7. Hello. I have a problem with tdma script. Me and my friends are going to play tdma on lan tommorow, but the problem is with vehicles. When a vehicle explodes with players inside it, scores don't update. I tried to add few lines, but it doesn't change anything, despite there are no errors shown. Here is the script: function xonPlayerWasted ( ammo, attacker, weapon, bodypart ) if ( xonPlayerWasted_Enabled ) then local vTeamID = getElementData ( source, "tdma.teamid" ) local vTeam = gameTeams[vTeamID] if not ( vTeam ) then setTimer ( firstSpawn, 3000, 1, source, vTeam ) else local a = setTimer ( respawnThePlayer, 3000, 1, source, vTeam ) if not ( a ) then respawnThePlayer ( source, vTeam ) end end if ( attacker ) then local pTeamID = getElementData ( attacker, "tdma.teamid" ) local pTeam = gameTeams[pTeamID] --Was it a self kill? if ( source ~= attacker and vTeamID ~= pTeamID ) then if ( pTeam ) then updateKills ( attacker, pTeam ) end end end ----THIS IS THE PART I ADDED----- if ( weapon == 63 ) then local TeamOne = gameTeams[1] local TeamTwo = gameTeams[2] outputChatBox ( "#FF0000First #FF0000part #FF0000works", getRootElement(), 255, 255, 255, true ) if ( vTeamID == TeamOne ) then updateKills ( teamTwo ) outputChatBox ( "#FF0000Second #FF0000part #FF0000works", getRootElement(), 255, 255, 255, true ) end if ( vTeamID == TeamTwo ) then updateKills ( teamOne ) outputChatBox ( "#FF0000Second #FF0000part #FF0000works", getRootElement(), 255, 255, 255, true ) end end end end addEventHandler ( "onPlayerWasted", root, xonPlayerWasted ) (I added these chat boxes just to test to see if it works)
  8. Ok, so here is my problem. When i host a game, I choose tdma resource and tdma map. When i start the game it says "spawning, please wait..." and after that nothing happens. What should I do?
×
×
  • Create New...