Hutchpe Posted November 8, 2012 Share Posted November 8, 2012 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. ERROR: Mexihunt\script.lua:134: attempt to call a table value Any help is greatly appreciated. Link to comment
Tete omar Posted November 8, 2012 Share Posted November 8, 2012 Change line 25 to for blipKey, blipValue in ipairs(blips) do Link to comment
Hutchpe Posted November 8, 2012 Author Share Posted November 8, 2012 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. Link to comment
Tete omar Posted November 8, 2012 Share Posted November 8, 2012 But where's the events ? Link to comment
Hutchpe Posted November 8, 2012 Author Share Posted November 8, 2012 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 ? Link to comment
TAPL Posted November 8, 2012 Share Posted November 8, 2012 function destroyBlipsAttachedTo is not defined anywhere. source in line 18 and 27 is not defined anywhere and it's not inside any function/event. And as Tete omar said, there no events in your code. Link to comment
Tete omar Posted November 8, 2012 Share Posted November 8, 2012 Here you can find client events https://wiki.multitheftauto.com/wiki/Cli ... ing_Events and server events https://wiki.multitheftauto.com/wiki/Ser ... ing_Events Link to comment
Hutchpe Posted November 9, 2012 Author Share Posted November 9, 2012 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. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now