Hutchpe
Members-
Posts
25 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
Hutchpe's Achievements
Advanced Member (8/54)
0
Reputation
-
Works great! Thanks so much
-
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
-
Thank you so much. It all makes sense now
-
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?
-
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
-
Everything is working great now! Thank you so much myonlake and eveyone else who helped me out here.
-
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?
-
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.
-
Ok I tried your code and it is still jumping straight to the else statement and I get the following error in console
-
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
-
Thanks for the reply MJNONFIK but I'm still getting the same error as before. EDIT: And still with your modified script.
-
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 )
-
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.
-
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)
-
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.
