Jump to content

tma

Members
  • Posts

    173
  • Joined

  • Last visited

Everything posted by tma

  1. tma

    setting gravity

    You have: setGravity ( 0.0035(level) ) I wrote: setGravity(tonumber(level))
  2. Like this: function assignNewTeam ( source, commandName, teamName ) local team = getTeamFromName(teamName) if team then setPlayerTeam ( source, team ) -- add the player to a team outputChatBox ( "test", source, 128, 206, 206 ) end end addCommandHandler ( "team", assignNewTeam ) This relies on the player entering the EXACT name of the team. Alternatively you could do partial team name matches (e.g. "race" for "Mad Racing") by spinning a loop through all "team" elements and doing you own string comparisons of the team name - getTeamName().
  3. tma

    setting gravity

    If your code is server side change the one line to: setPlayerGravity(sourcePlayer,tonumber(level)) That's per-player. For the server (i.e. everyone): setGravity(tonumber(level))
  4. Just use setElementInterior() and supply your interior id with the appropriate x,y,z for the location. Here's a full(?) interior list I made in XML : http://pastebin.com/f255e62b7 (based off szlend's original list).
  5. Just use setElementInterior() and supply your interior id with the appropriate x,y,z for the location. Here's a full(?) interior list I made in XML : http://pastebin.com/f255e62b7 (based off szlend's original list).
  6. You're only setting the interior of the player - is that right ? Should you try setting the vehicles instead or both ? Also, your warnings are because when you set the timer, you need to pass the player variable so it will be passed to the unfreeze bit. Like: setTimer( unfrozen, 3000, 1, player)
  7. You're only setting the interior of the player - is that right ? Should you try setting the vehicles instead or both ? Also, your warnings are because when you set the timer, you need to pass the player variable so it will be passed to the unfreeze bit. Like: setTimer( unfrozen, 3000, 1, player)
  8. tma

    Could not bind...

    Try: + Your HTTP port on a different value to that of your server port. + Set 'httpdownload' to '1'
  9. A few things: + return x,y (already pointed out) + It's probably x = x - math.sin(...) (not x = x + ) + rotation as returned from getPlayerRotation() is in degrees. math.sin/cos are in radians so you'll need math.rad() in there.
  10. But it does return only one player ? The two variables being assigned on function return are the closest element (player if you want, of any other element type) and the distance it is from the source player.
  11. No offence but why don't you just use my code above ? It does what you want and works. In your code you've way more errors than you think: + Yeah, that i++ should be i=i+1 (as has been pointed out) + You have the same problem with maxdis on the following line + You return "j" but j was set locally in an "if block" so it won't have a value to return. + You don't need recursion to do this - what you're going to end up with if you get it working is a check through all players at one distance. If that fails, you're going to keep calling it with every-decreasing values for "maxdis". Think about how much processing you're going to require just to find the closest. You only need to loop through the elements once to find the closest. If you did use my code then to find the closest player to "player" you'd just use: local playerClosest,distance = tuFindNearestElement(player,"player",100) This would set playerClosest to the player element that is closest to the first parameter player - our target (or nil if no other player is found).
  12. tma

    XML Suggestion

    Excellent - thanks!
  13. tma

    XML Suggestion

    I've writing code to save data arrays into XML which can be done fine with the current API e.g. function tuTableToXML(tbl,nodeName,node) for key,value in pairs(tbl) do if type(value) == "table" then tuTableToXML(value,key,xmlCreateSubNode(node,key)) else xmlNodeSetAttribute(xmlCreateSubNode(node,nodeName),key,value) end end end function tuTableToXMLFile(tbl,rootNodeName,fsp) local xf = xmlCreateFile(fsp,rootNodeName) tuTableToXML(tbl,rootNodeName,xf) return xmlSaveFile(xf) end This will traverse any array and save the contents to an XML file like: > > > id="580" /> upgrade="1101" /> > > id="479" /> > > dead="43" /> sb="0" /> vc="0" /> > The problem I've got now is that I want to be able to read this back into the array. I've looked at the API and the commands aren't there to do it - there's nothing to arbitrarily read back XML data. I check out _arc's racemap conversion source and noticed that to do this with a race map, he passes the structure of the file to his decoding routine. I'm looking for something wherein I can just read any XML without knowing the structure, into an array. In DP3, xmlNodeGetChildren() will allow the fetching of all the child nodes, but it doesn't solve the problem entirely. Would it be possible to add the following two functions ? xmlNodeGetTag(node): Returns the tag of the given node e.g. "stat", "vfav", "sillycar" etc. in the above example. I've tried xmlNodeGetValue() but this never seems to return anything (I assume value ~= tag ?) xmlNodeGetAttributes(node): Returns a list of the attributes for a given node. Eg. for something like : id="479" color="1,1" upgrades="1110" /> it would return an array like {"id","colour","upgrades"} Any chance of these additions ?
  14. I use something like: function tuFindNearestElement(to,elementType,maxDistance) local x,y,z = getElementPosition(to) local bestD = maxDistance + 1 local bv = nil for _,av in pairs(getElementsByType(elementType)) do if av ~= to then local vx,vy,vz = getElementPosition(av) local d = getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) if d < bestD then bestD = d bv = av end end end return bv,bestD end You call it like: local vehicleClosest,distance = tuFindNearestElement(player,"vehicle",100) This finds the closest "vehicle" to the "player" within a distance of 100 units.
  15. How does this even work ? addEventHandler ( "onVehicleSpawn", root, onVehicleSpawn ) addEventHandler ( "onVehicleDstroy", root, onVehicleDestroy ) onVehicleSpawn() should be onVehicleRespawn() ? onVehicleDstroy() (sic) should be onVehicleExplode() ? Even then it won't catch all vehicle clearances - only those that explode.
  16. Just make the marker AND a col shape. That way you can see the gas station and refill in the col shape - I think this would work much better than binding keys to small amounts of fuel. You could a HUD display showing the fuel refilling and your money dropping. When done you just drive away.
  17. In util_server.lua from the Race mod, there's a function setVehiclePaintjobAndUpgrades() - I'd call your code from there. This ways it's not constantly on a timer setting values for the vehicle. Maybe it'd be nice in the next Race update to throw a Race-defined event (similar to entering the vehicle), so that code such as yours, could trap it and setup further car mods.
  18. This is normal in any language - see malloc/free in C. The "value" returned from malloc is a pointer (reference) to the memory block. The same thing happens with MTA elements - variables point to the type data but aren't the type themselves (references).
  19. This is a nice idea, thanks. I wrote a with it.
  20. I was looking over your script and was wondering why do you have this code in there ? function drawFuelBar() fBar = guiCreateProgressBar(598,158,154,25,false) guiSetVisible(fBar,false) end addEventHandler("onClientPlayerJoin",getRootElement(),drawFuelBar) You make a fuel bar in onClientResourceStart(). Won't this then remake a fuel bar each time a player joins ?
  21. Nope. I mean remove one line from updateList() and add one to showTextIcon() (as shown above). Edit: Why don't you contact the original author and just have him implement the original bandwidth-reducing change I made ?
  22. I meant in the function "updateList()" REMOVE the line that's like "guiSetVisible(...)". The other snippet was an INCOMPLETE function - I was just showing you were to paste this line: guiSetVisible(chatIconFor[player], false) into the function "showTextIcon()" i.e. put it just after the "for" loop. It's similar to the one you've removed but not the same.
  23. You've changed one line - I meant for you to remove one and add another.
  24. Had a look at the code: I can see why the chat icon is having a problem. After sending the chat pulse form the client, the server sends it back to all players at which point their icon is hidden until the frame render event handler decides wether or not to show it. So if I cut down the bandwidth for you, you get a sticky icon. A suggestion would be to go into ktypestatus_cl.lua and: Remove the guiSetVisible() line from: function updateList(newEntry, newStatus) chattingPlayers[newEntry] = newStatus if(not chatIconFor[newEntry]) then chatIconFor[newEntry] = guiCreateStaticImage(0, 0, guix, guiy, "chatbubble.png", false ) end guiSetVisible(chatIconFor[newEntry], false) -- << REMOVE end and put something similar into: function showTextIcon() local playerx,playery,playerz = getElementPosition ( getLocalPlayer() ) for player, truth in pairs(chattingPlayers) do guiSetVisible(chatIconFor[player], false) -- << ADDED ... See if that helps.
  25. But could you just try the old version again and try to recreate the problem ? You see, I only changed the rate of data sent. Admittedly, I haven't look at the server side of this so it's plausible that it may reply to the client and "control" wether or not the icon is displayed. I would have thought this to be inside the client code. Maybe the original author could adopt the change I made and implement it ?
×
×
  • Create New...