Jump to content

Hutchpe

Members
  • Posts

    25
  • Joined

  • Last visited

Everything posted by Hutchpe

  1. Works great! Thanks so much
  2. Sorry for intruding on this thread but I have a similar problem. When I get in a vehicle it starts playing the sound but when I get out of the vehicle or issue the 'stopsound' command the sound won't stop. function startGarageMusic() local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) local sound = playSound("saints_row_garage.mp3", true) setRadioChannel(0) setSoundVolume( sound, 0.8 ) end addEventHandler("onClientVehicleEnter",getRootElement(),startGarageMusic) function stopGarageMusic() stopSound( sound ) end addCommandHandler ( "stopsound", stopGarageMusic ) addEventHandler("onClientVehicleExit",getRootElement(),stopGarageMusic) Can someone point me in the right direction? Thanks
  3. Thank you so much. It all makes sense now
  4. So just to make sure I'm doing this right. I have this in my meta.xml file <script src="musicstream.lua" type="client" /> Should the whole 'musicstream' resource folder be downloaded to the mods/deathmatch folder in my MTA directory?
  5. Hey everyone, First off please forgive me if this is in the wrong section. I have been searching for a while and have not been able to find out how a client downloads a client side script from the server. I understand how to make client side scripts and define them in meta.xml file but that's as far as I have got. Could someone please point me in the right direction as to how I can get it to work? Thanks
  6. Everything is working great now! Thank you so much myonlake and eveyone else who helped me out here.
  7. The team name is Mexicans so I'm not sure why it isn't working. Below is the code I have to create the teams and then for the player to join the teams. function createTeamsOnStart () createBlip ( 2491.2993164063, -1665.7626953125, 13.34375, 3 ) --snuck this in here BorderControl = createTeam ( "Border Control", 0, 0, 255 ) Mexicans = createTeam ( "Mexicans", 255, 0, 0 ) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) addCommandHandler("joinmexicans", function(thePlayer, commandName) spawnPlayer(thePlayer, 364.96685791016, 2507.6645507813,16.496768951416, 0,173,0,0,Mexicans) outputChatBox("You are a Mexican.",thePlayer) end ) addCommandHandler("joinbordercontrol", function(thePlayer, commandName) spawnPlayer(thePlayer, -1602.9626464844,660.72479248047,7.1875, 0,71,0,0,BorderControl) outputChatBox("You are the Border Control.",thePlayer) end ) Is there anything wrong with the code I have here that would be causing your script not to work?
  8. Thankyou so much myonlake and MJNONFIK and sorry that my code was such a mess . Anyway I have tried both your scripts. myonlake yours says that I'm not on the Mexican team even though I am. MJNONFIK yours gives me the following errors in the console when I start the resource.
  9. Ok I tried your code and it is still jumping straight to the else statement and I get the following error in console
  10. Line 138 has the following local team = getPlayerTeam (source) This is start of the script as it is currently function objective(thePlayer, matchingDimensions) local team = getPlayerTeam (source) if isElementWithinMarker(thePlayer, objectivemarker) and getTeamName(team) == teamMexicans then With the above script I am now getting the previous error and the below error I go into the marker
  11. Thanks for the reply MJNONFIK but I'm still getting the same error as before. EDIT: And still with your modified script.
  12. Hi everyone I'm having some trouble working out what's wrong with my script. What it is supposed to do is create a marker, when a player enters it check if they are on a certain team and if they are then reload 2 resources and spawn the player at a spawn point. At the moment it is creating the marker but nothing happens when a player from either team enters it. objectivemarker = createMarker( 2491.2993164063, -1665.7626953125, 12.34375, "cylinder", 2.0, 255, 0, 0, 255 ) function objective(thePlayer, matchingDimensions) local team = getPlayerTeam (source) if isElementWithinMarker(thePlayer, objectivemarker) and (team == teamMexicans) then outputChatBox ( "Mexicans Have Won!" ) outputChatBox ( "Loading Next Round! Please Wait" ) setTimer ( function() local players = getElementByType ( "player" ) reloadResource "Mexihunt" reloadResource "Teamblips" spawnPlayer( players, 1544.4279785156, -1353.2464599609, 329.47442626953 ) end, 5000, 1 ) else outputChatBox ( "You aren't a Mexican" ) end end addEventHandler ( "objective", getRootElement(), objective ) I'm not getting any errors in the console with the following script. Any help is greatly appreciated. (Also sorry for my recent spate of requests for help . I'm rather new to programming and learning as quickly as I can )
  13. Before looking through it before making any significant changes I realised that I didn't need to be destroying blips when a player was wasted and that it was causing all the issues. Here is the fully working script for anyone else having similar issues. root = getRootElement () color = { 0, 255, 0 } players = {} resourceRoot = getResourceRootElement ( getThisResource () ) function onResourceStart ( resource ) for id, player in ipairs( getElementsByType ( "player" ) ) do if ( players[source] ) then createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) elseif getPlayerTeam(player) then local r, g, b = getTeamColor(getPlayerTeam(player)) createBlipAttachedTo ( player, 0, 2, r, g, b ) else createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) end end end function onPlayerSpawn ( teamMexicans ) if ( players[source] ) then createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) elseif getPlayerTeam(source) then local r, g, b = getTeamColor(getPlayerTeam(source)) createBlipAttachedTo ( source, 0, 2, r, g, b ) else createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) end end function onPlayerSpawn ( teamBorderControl ) if ( players[source] ) then createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) elseif getPlayerTeam(source) then local r, g, b = getTeamColor(getPlayerTeam(source)) createBlipAttachedTo ( source, 0, 2, r, g, b ) else createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) end end function onPlayerQuit () destroyBlipsAttachedTo ( source ) end function setBlipsColor ( source, commandName, r, g, b ) if ( tonumber ( b ) ) then color = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } for id, player in ipairs( getElementsByType ( "player" ) ) do destroyBlipsAttachedTo ( player ) if ( players[player] ) then createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) end end end end function setBlipColor ( source, commandName, r, g, b ) if ( tonumber ( b ) ) then destroyBlipsAttachedTo ( source ) players[source] = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) end end addCommandHandler ( "setblipscolor", setBlipsColor ) addCommandHandler ( "setblipcolor", setBlipColor ) addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) function destroyBlipsAttachedTo(player) local attached = getAttachedElements ( player ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end Also thankyou Scooby for your help.
  14. So I am running a modified version of the 'playerblips' resource to allow for coloured blips based on the team colours. The problem I'm having is that when a player dies their blip is no longer visible on the radar to everyone else. Here is the modified script I'm using. root = getRootElement () color = { 0, 255, 0 } players = {} resourceRoot = getResourceRootElement ( getThisResource () ) function onResourceStart ( resource ) for id, player in ipairs( getElementsByType ( "player" ) ) do if ( players[source] ) then createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) elseif getPlayerTeam(player) then local r, g, b = getTeamColor(getPlayerTeam(player)) createBlipAttachedTo ( player, 0, 2, r, g, b ) else createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) end end end function onPlayerSpawn ( spawnpoint ) if ( players[source] ) then createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) elseif getPlayerTeam(source) then local r, g, b = getTeamColor(getPlayerTeam(source)) createBlipAttachedTo ( source, 0, 2, r, g, b ) else createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) end end function onPlayerQuit () destroyBlipsAttachedTo ( source ) end function onPlayerWasted ( totalammo, killer, killerweapon ) destroyBlipsAttachedTo ( source ) end function setBlipsColor ( source, commandName, r, g, b ) if ( tonumber ( b ) ) then color = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } for id, player in ipairs( getElementsByType ( "player" ) ) do destroyBlipsAttachedTo ( player ) if ( players[player] ) then createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) end end end end function setBlipColor ( source, commandName, r, g, b ) if ( tonumber ( b ) ) then destroyBlipsAttachedTo ( source ) players[source] = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) end end addCommandHandler ( "setblipscolor", setBlipsColor ) addCommandHandler ( "setblipcolor", setBlipColor ) addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) addEventHandler ( "onPlayerWasted", root, onPlayerWasted ) function destroyBlipsAttachedTo(player) local attached = getAttachedElements ( player ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end I have no idea why it isn't working and I don't get any error messages in the console. Can someone please point me in the right direction to get this working? Any help is greatly appreciated. (I did have another topic similar to this but the script is significantly different so it was no longer relevant)
  15. Ok thanks for the help guys. I added in events and now blips are being created properly with no issues! There are only two remaining problems and one of them is with the blip colours. I have rewritten the script for it but it is changing all blip colours to red instead of red for one team and blue for the other. I get a message in console saying "WARNING: Bad argument @ 'setBlipColor' [C]" Here is what I have written. function onPlayerSpawn ( spawnpoint ) local team = getPlayerTeam (source) local blips = getElementsByType ( "blip" ) if (team == teamMexicans) then setBlipColor ( blips, 255, 0, 0, 255 ) else setBlipColor ( blips, 0, 0, 255, 255 ) end end addEventHandler ( "onPlayerSpawn", root, setBlipColor ) The last problem is that when a player disconnects, their blip is not destroyed. This is all I currently have that destroys players blips on quit. function onPlayerQuit () destroyBlipsAttachedTo ( source ) end addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) If I add this on the end of my script it destroys the blips properly when a player quits but when you kill another player you can no longer see them on radar which puts me back at step 1 again. function destroyBlipsAttachedTo(player) local attached = getAttachedElements ( player ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end Any help is greatly appreciated. EDIT: I've changed the code significantly since this and the code here is no longer relevant.
  16. I'm a bit of a noob when it comes to Lua scripting and I'm not sure which events to use . Could you perhaps point me in the right direction or give an example keeping my noobishness in mind ?
  17. Thanks for the reply but I'm still getting the same error when I start the server and there are still no blips being displayed on the radar.
  18. Ok so I am trying to configure player blips for my server. I was initially running the 'playerblips' resource which was creating blips for the players but when a player was killed the killer could no longer see the victim on the radar when they respawned. I then attempted to write my own script with no success. The overall aim is for a blip of a certain colour to be created for a player when the join a team or respawn. Here is what I have written. function onPlayerSpawn ( spawnpoint ) --creates blip for player on team join local team = getPlayerTeam (source) if (team == teamMexicans) then createBlipAttachedTo ( source, 0) end end function onPlayerSpawn ( spawnpoint ) --creates blip for player on team join local team = getPlayerTeam (source) if (team == teamBorderControl) then createBlipAttachedTo ( source, 0) end end blips = getElementsByType ( "blip" ) --sets blip colour for blipKey, blipValue in blips do red, green, blue, alpha = getBlipColor ( blipValue ) local team = getPlayerTeam (source) if (team == teamBorderControl) then setBlipColor ( blipValue, 0, 0, 255, 255 ) end end blips = getElementsByType ( "blip" ) --sets blip colour for blipKey, blipValue in blips do red, green, blue, alpha = getBlipColor ( blipValue ) local team = getPlayerTeam (source) if (team == teamMexicans) then setBlipColor ( blipValue, 255, 0, 0, 255 ) end end function onPlayerQuit () destroyBlipsAttachedTo ( source ) end function onPlayerWasted ( totalammo, killer, killerweapon ) destroyBlipsAttachedTo ( source ) end Using the following code I also get get this error in console when starting the server. Any help is greatly appreciated.
  19. Thanks so much myonlake and TAPL. It's all working great now.
  20. Ok I this is what used the code you helped me fix but whenever I start the server I get a message saying This is what the code currently looks like addEventHandler("onPlayerWasted", root, function playerWasted(ammo, killer, weapon, bodypart, stealth) local team = getPlayerTeam (source) if (team == teamBorderControl) then spawnPlayer(source, -1602.9626464844, 660.72479248047, 7.1875, 0, 71, 0, 0, teamBorderControl) end end ) addEventHandler("onPlayerWasted", root, function playerWasted(ammo, killer, weapon, bodypart, stealth) local team = getPlayerTeam (source) if (team == teamMexicans) then spawnPlayer(source, 364.96685791016, 2507.6645507813, 16.496768951416, 0, 71, 0, 0, teamMexicans) end end ) Can anyone see what's wrong with the code?
  21. Thanks to the help of some wonderful members I got team spawning working nicely. Now I have come across another problem. Whenever someone on a team dies they don't respawn and the camera just stays hovering above their body until they either reconnect or change teams. Here is the current team spawn scripts. addCommandHandler("joinmexicans", function(thePlayer, commandName) spawnPlayer(thePlayer, -1502,-146,14.1484375, 0,173,0,0,teamMexicans) outputChatBox("You are a Mexican.",thePlayer) end ) addCommandHandler("joinbordercontrol", function(thePlayer, commandName) spawnPlayer(thePlayer, -1346,-213,14.1484375, 0,71,0,0,teamBorderControl) outputChatBox("You are the Border Control.",thePlayer) end ) I've had a shot at writing a respawn script but my very limited knowledge in Lua has meant that it's a failure addEventHandler("onPlayerWasted", root, function playerWasted () local team = getPlayerTeam (source) if (team == teamBorderControl) then spawnPlayer(thePlayer, -1346,-213,14.1484375, 0,71,0,0,teamBorderControl) end end ) Can anyone point me in the right direction? Also my last questions are is it possible to write a script that checks to see if anyone on a team is alive and if no one is then reload the resource? and Is it possible to have players show up on the radar in the MTA:SA game mode? Sorry if some questions are a bit of topic. Any help is much appreciated.
  22. It works great! Thanks so much
  23. Sorry for being a bit of a noob but could you show me what they would look like put together? So far I have the script to join a team addCommandHandler("joinbordercontrol", function(thePlayer, commandName) spawnPlayer(thePlayer, 2495.3654785156,-1687.6867675781,13.517179548035, 0,0,0,0,teamBorderControl) fadeCamera (source, true) setCameraTarget (source, source) outputChatBox("You are the Border Control.",thePlayer) end ) and the giveWeapons script function giveWeaponsOnSpawn ( theSpawnpont, theTeam ) giveWeapon ( source, 31, 200 ) end addEventHandler ( "onPlayerSpawn", getRootElement(), giveWeaponsOnSpawn )
  24. Thanks for the reply. I replaced setPlayerTeam with spawnPlayer and it works beautifully! I've decided to scrap the .MAP config and implement weapons through the script. Can anyone give some advice on how to use the giveWeapon argument only when a player joins a specific team?
  25. I am in the process of creating scripts for my server. The aim is to have two teams and when a player joins a team they are teleported to a set of co-ordinates. I currently have the script to create the teams on start-up and to let people join the teams. function createTeamsOnStart () teamBorderControl = createTeam ( "Border Control", 0, 255, 0 ) teamMexicans = createTeam ( "Mexicans", 200, 0, 100 ) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) and addCommandHandler("joinmexicans", function(thePlayer, commandName) setPlayerTeam(thePlayer, teamMexicans) outputChatBox("You are a Mexican.",thePlayer) end ) addCommandHandler("joinbordercontrol", function(thePlayer, commandName) setPlayerTeam(thePlayer, teamBorderControl) outputChatBox("You are the Border Control.",thePlayer) end ) Can anyone point me in the right direction to modify this so that when a player joins a team they are teleported to specific co-ordinates? I am also wanting to know how to apply attributes in the MAP file to each of the teams. This is what I have in the map file currently. "Mexihunt" version="1.0"> "5000" maxkills="60" ff="off"/> "00" h="10" locked="false" /> team="Border Control" red="255" green="0" blue="0"> "9" ammo="1"/> "23" ammo="100"/> "25" ammo="200"/> "32" ammo="500"/> "31" ammo="200"/> "33" ammo="50"/> "33"/> "5438.780762" posY="-1917.095703" posZ="1.538315" rot="0" randx="0" randy="0" randz="0"/> "5429" posY="-1831" posZ="3.22" rot="0" randx="0" randy="0" randz="0"/> "5253" posY="-2075" posZ="5.24" rot="0" randx="0" randy="0" randz="0"/> "5424" posY="-2060" posZ="9.09" rot="0" randx="0" randy="0" randz="0"/> team="Mexicans" red="255" green="255" blue="255"> "3" ammo="1"/> "24" ammo="100"/> "27" ammo="200"/> "29" ammo="500"/> "30" ammo="200"/> "34" ammo="50"/> "70"/> "5068.007813" posY="-2083.547119" posZ="7.487796" rot="0" randx="0" randy="0" randz="0"/> "5141" posY="-1873" posZ="6.66" rot="0" randx="0" randy="0" randz="0"/> "5095" posY="-1938" posZ="16.87" rot="0" randx="0" randy="0" randz="0"/> "5067" posY="-2068" posZ="14.8" rot="0" randx="0" randy="0" randz="0"/> "5099" posY="-2084" posZ="15.53" rot="0" randx="0" randy="0" randz="0"/> Any help is very much appreciated.
×
×
  • Create New...