Jump to content

Mr_Moose

Members
  • Posts

    866
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Mr_Moose

  1. First of all you don't need to loop threw all the hit blips when one of the hits die (that's the reason for removing all blips), secondly the element data looked a little bit wrong as well and you got two end calls to much in the beginning, not sure if it worked or not in the first place but here you go. This should work. hitBlip = { } function hitme ( thePlayer, commandName, moneyAmount ) local playermoney = getPlayerMoney ( thePlayer ) if playermoney < tonumber(moneyAmount) then outputChatBox ( "You dont have enough money to make hit",thePlayer,255,0,0, false ) else amount = tonumber(moneyAmount) if amount > 500000 then outputChatBox ( "Maximum hit amount is $500000", thePlayer,255,0,0, false ) elseif amount < 50000 then outputChatBox ( "Minimum hit amount is $50000", thePlayer,255,0,0, false ) elseif ( getElementData ( thePlayer, 'Player' ) == 'Hit' ) then outputChatBox ( "You are already a hit", thePlayer,255,0,0, false ) else local playername = getPlayerName ( thePlayer ) hisBlip = createBlipAttachedTo ( thePlayer, 26 ) hitBlip[thePlayer] = hisBlip -- Store the hitblip assigned to the hit player in the global table setPlayerNametagColor ( thePlayer, 0, 0, 0 ) takePlayerMoney ( thePlayer, amount ) setElementData ( thePlayer, "isHit", true ) outputChatBox ( "You have placed a $" .. amount .. " hit on your self",thePlayer,255,235,0, false ) outputChatBox ( "A hit has been placed on " .. playername .. " For $" .. amount .. ".",root,255,235,0, false ) end end end addCommandHandler ("hitme", hitme) function ondie () if getElementData ( source, "isHit" ) then removeElementData( source, "isHit" ) setPlayerNametagColor ( source, 255, 255, 0 ) destroyElement( hitBlip[source] ) end end addEventHandler ( "onPlayerWasted", getRootElement(), ondie ) The table will now store the blip pointer and assign it to the player which is a hit, when he dies, he's blip will be removed, element data is now a value named "isHit" which is set to true when a player is a hit, verifyed by getElementData and finally removed by removeElementData using correct syntax, by using indentation it's also way more easy to read the code which I recomend you to use in the future. Good luck with this now.
  2. Use "client" instead of "source" in those functions that passes a player from the client script to the server script by triggerServerEvent. Lines: 24, 31, 39, 51, 63, 74, 85. Otherwise you will get some issues as soon there are more than 1 players online in your server and someone uses this feature since source may point at the wrong player.
  3. This is the resource that brings life to all the train tracks around San Andreas, by spawning trains with attached carriages allover the tracks on certain triggers. In this topic I will explain how it all works and how to install and configure it. Download link: http://code.albonius.com/?action=download&id=568586d994ef88c80b2eb46b4860fc16 https://github.com/GTWCode/GTW-RPG/tree/master/%5Bresources%5D/GTWtrain Help and support: Bug reports Related questions Screenshot Live demo: mtasa://gs.gtw-games.org:22005 Demo video https://www.youtube.com/watch?v=gO6atdRgduE Description of the files: Latest release: 2.0.0 is highly optimized compared to earlier versions, uses built in functions from MTA 1.4 which improves the carriages sync a lot. This version also comes with passenger trains (brown streak). As usual 100% open source, customizable parameters (see below) and much more to make the trains just like real trains who works out of the box and makes the game more interesting. Settings: maxAttachedTrailers: the maximum amount of attached trailers that can be added to a train, (locomotives also counts) minAttachedTrailers: the minimum amount of attached trailers that can be added to a train, (locomotives also counts) compensationSpeed: This is multiplied with the syncer and determine how fast the trailers will move when they get far away from the locomotive, should be above 7 to avoid being too slow and below 15 on a long train to prevent derails. streamOut: Set this to false to prevent the trailers from spawning in different tracks after the train has been streamed out, set it to true if you want a large amount of short trains. allowDoubleEngines: Specify if longer trains should be able to spawn with 2 locomotives allowBoxTrailers: Set this to true and some of the trailers will be of the type box freight instead of flat trailers. cleanUpDistance: How far away the nearest player can go from the locomotive before the train is cleaned up (removed) maxSyncDistance: How far away from the nearest player the train will stay synced, above this distance the train will compress to it's origional state, the trailers will basically go into eachothers and the train will stop to prevent derails. maxNumberOfTrains: How many trains that can exist at the same time in the entire server. timeToNextTrain: Global timer in seconds before a new train can be created timeNextTrainInterval: How long time in seconds a player needs to wait in case he misses his train on the station for instance. maxSpeed: (Global) How fast will the train ever go, note that it may derail above 1 (160km/h) minSpeed: (Global) Lowest possible speed, the train can't stop completely on the stations yet but this allow them to go close enough stop without getting stuck, should not be lower than 0.01 (Recommendation) accelerationConst: This value is divided from the distance to the nearest train station and indicates how fast the train will slow down or speed up when it reaches the train station. 300 Debugmodes Setting this value to 0 means it's live. Setting this value to 1 will show all the trigger markers as in a semi transparent black color Setting this value to 2 will show trigger markers and spawn markers as transparent white. This makes it easy to add new locations or index new train tracks in the future. Spawn points Array of x,y,z, direction (bool) locations where a train can be spawned. This should be placed carefully to make sure that the trains stay on the track you want it on for instance. Trigger points (markers) Invisible markers that trigger the train creation function as soon a player with or without vehicle (not another train tho) hit's the marker and becomes the element syncer of the train that appears. Train Locations This is the list of train stations, taken from AC train driver job which isn't published yet but you find it in our server as well. Any suggestions for future improvements are welcome here in this thread, enjoy!
  4. Mr_Moose

    Cars

    Look at the code again and you'll find the most obvious issues in it, first one is in the server where you define: local vehicle = {} 7 times, data variables should only be defined once. The next issue is the usage of source on the server which sometimes passes the wrong player from the client, use "client" instead. Issue 3, mixing of the event handlers both on server and client, why not write: addEvent( 'car5', true ) addEventHandler( 'car5', root,function() instead of: addEvent( 'car5', true ) addEventHandler( 'car', root,function() And most hilarious parts, why are you creating the same function 7 times, it only need to be created once with different arguments, applies both for client and server btw. There you go
  5. Mr_Moose

    Jail system

    You could use setElementData server side to store the time when the player should be released and then use dxDrawText on the client to show the result for the player. When the player is released or leave the server simply set his jail time to nil and on the client you check if there is a value associated with the player and draw the text. Remember that dxDrawText must be used in onClientRender if you want the user to actually see the time.
  6. dxDrawText onClientRender setPlayerNametagShowing That's all functions you need.
  7. This may help you as well, a complete resource for vehicle spawn from gui on marker hit, open source and fully customizabled. If you want to use it or just copy the code part you need is up to you but it's a good option at least. https://community.multitheftauto.com/index.php?p=resources&s=details&id=8338
  8. Sounds can easily be played on the client by using the playSound function: element playSound ( string soundPath, [ bool looped = false ] ) https://wiki.multitheftauto.com/wiki/PlaySound Set the soundPath to a sound file url or include the sound in the resource, I would recommend the first alternative. To stop the sound you can use destroyElement() with the sound element as argument.
  9. Mr_Moose

    help

    Did you tested the script by yourself or together with someone else? "onClientPlayerJoin" and "onClientPlayerQuit" will not trigger for the source player which is you in this case, it will only trigger for you when another player join or quit from the server, just asking since the updated code from TAPL seems ok.
  10. Not sure what you are trying to do here but if you want the marker to be added relative to the position of the player onColShapeHit then you should get the player position just before you create the marker and not in the loading code. You should also note that onColShapeHit is a server sided event and since you use "localPlayer" in your code I assume that you are trying to make a client sided script. Therefore you should use: "onClientColShapeHit" instead. Maybe you should post the code since it's hard to know what you are trying to do here.
×
×
  • Create New...