kevin11 Posted June 20, 2010 Posted June 20, 2010 solidsnake14 made this ones function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local r, g, b = getPlayerNametagColor ( source ) setAccountData ( playeraccount, "ColorRed", r ) setAccountData ( playeraccount, "ColorGreen", g ) setAccountData ( playeraccount, "ColorBlue", b ) end end function onPlayerLogin ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local tagColorRed = getAccountData ( playeraccount, "ColorRed" ) local tagColorGreen = getAccountData ( playeraccount, "ColorGreen" ) local tagColorBlue = getAccountData ( playeraccount, "ColorBlue" ) if tagColorRed and tagColorGreen and tagColorBlue then setPlayerNametagColor ( source, tagColorRed, tagColorGreen, tagColorBlue ) end end end function onPlayerSpawn ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local tagColorRed = getAccountData ( playeraccount, "ColorRed" ) local tagColorGreen = getAccountData ( playeraccount, "ColorGreen" ) local tagColorBlue = getAccountData ( playeraccount, "ColorBlue" ) if tagColorRed and tagColorGreen and tagColorBlue then setPlayerNametagColor ( source, tagColorRed, tagColorGreen, tagColorBlue ) end end end function onPlayerWasted ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local r, g, b = getPlayerNametagColor ( source ) setAccountData ( playeraccount, "ColorRed", r ) setAccountData ( playeraccount, "ColorGreen", g ) setAccountData ( playeraccount, "ColorBlue", b ) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) addEventHandler ( "onPlayerWasted", getRootElement ( ), onPlayerWasted ) addEventHandler ( "onPlayerSpawn", getRootElement ( ), onPlayerSpawn ) AND i was making kinda the same but then saving car colors 1-2 function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local r, g, b = getVehicleColor ( source ) setAccountData ( playeraccount, "vehColorRed", r ) setAccountData ( playeraccount, "vehColorGreen", g ) setAccountData ( playeraccount, "vehColorBlue", b ) end end function onPlayerLogin ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local vehColorRed = getAccountData ( playeraccount, "ColorRed" ) local vehColorGreen = getAccountData ( playeraccount, "ColorGreen" ) local vehColorBlue = getAccountData ( playeraccount, "ColorBlue" ) if vehColorRed and vehColorGreen and vehColorBlue then setVehicleColor ( source, vehColorRed, vehColorGreen, vehColorBlue ) end end end function onPlayerSpawn ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local vehColorRed = getAccountData ( playeraccount, "ColorRed" ) local vehColorGreen = getAccountData ( playeraccount, "ColorGreen" ) local vehColorBlue = getAccountData ( playeraccount, "ColorBlue" ) if vehColorRed and vehColorGreen and vehColorBlue then setVehicleColor ( source, vehColorRed, vehColorGreen, vehColorBlue ) end end end function onPlayerWasted ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local r, g, b = getVehicleColor ( source ) setAccountData ( playeraccount, "vehColorRed", r ) setAccountData ( playeraccount, "vehColorGreen", g ) setAccountData ( playeraccount, "vehColorBlue", b ) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) addEventHandler ( "onPlayerWasted", getRootElement ( ), onPlayerWasted ) addEventHandler ( "onPlayerSpawn", getRootElement ( ), onPlayerSpawn ) but its not working it gives the error bad eventhandler (no lines or anything) can anyone help, because tag color and veh color may not overwrite each other if soeone dies i get this error warning: 30-38: bad argument @ setvehiclecolor
kevin11 Posted June 20, 2010 Author Posted June 20, 2010 i noticed some bugs myself so i changed it a little
dzek (varez) Posted June 20, 2010 Posted June 20, 2010 we see your topic. be patient and dont bump it Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
LonelyRoad Posted June 20, 2010 Posted June 20, 2010 (edited) Ok, first thing I notice is you seem to be using "setVehicleColor" wrong. It does not go by r, g, b. Each car has different colour 'boxes' and each argument given to "setVehicleColor" is the colour ID for each box, not the RGB values for just one 'box'. Also, your trying to set the vehicle colour of the player? this obviously won't work. Study this page: https://wiki.multitheftauto.com/wiki/SetVehicleColor An example from me, for the usage of setVehicleColor is: local myCar = createVehicle(496, 0, 0, 0) function MyCarColour(myCar) setVehicleColor(myCar, 3) end ^The example above would spawn a Blista Compact(496) at the co-ords of 0,0,0 (x,y,z) and then set the vehicle's colour to red. Edited June 22, 2010 by Guest
Castillo Posted June 21, 2010 Posted June 21, 2010 anymore help yes, start to learn by yourself some time San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
TheRealCow Posted June 21, 2010 Posted June 21, 2010 kevin, setVehicleColor must added whit ID-s, not RGB Server Name: mR|Team Clan Race Server Server IP: 84.82.81.225:22004
Castillo Posted June 22, 2010 Posted June 22, 2010 here it is, should work ( at least in my server did ) server.lua function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local c1 = nil local c2 = nil local c1,c2,c3,c4 = getVehicleColor (getPedOccupiedVehicle(source)) setAccountData (playeraccount, "carcolor1", c1) setAccountData (playeraccount, "carcolor2", c2) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) function onPlayerLogin ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local c1 = nil local c2 = nil local c1 = getAccountData ( playeraccount, "carcolor1" ) local c2 = getAccountData ( playeraccount, "carcolor2" ) if c1 and c2 then veh = getPedOccupiedVehicle(source) if veh then setVehicleColor ( veh, c1, c2, 0, 0 ) end end end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
LonelyRoad Posted June 22, 2010 Posted June 22, 2010 (edited) The code in the post above will work, but only if they're in a car AS SOON AS the player logs in (which has a really slim chance of being possible by common practice, as if the player has any reason to login they'd do that first. unless you make your own event (if you use a custom login system) and trigger it when they login.) It will also only work if the car has two colours (which most don't). Edited June 22, 2010 by Guest
Castillo Posted June 22, 2010 Posted June 22, 2010 The code in the post above will work, but only if they're in a car AS SOON AS the player logs in (which has a really slim chance of being possible by common practice, as if the player has any reason to login they'd do that first, unless you make your own event (if you use a custom login system) and trigger it when they login.It will also only work if the car has two colours (which most don't). i just made an example of how to do it. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
LonelyRoad Posted June 22, 2010 Posted June 22, 2010 i just made an example of how to do it. Yes, I know. Off-topic: Your 14 years old and you love the MGS series, a good conclusion, yes?
kevin11 Posted June 22, 2010 Author Posted June 22, 2010 hes not 14 anyway i added wasted (save) and changed login to spawn i get this error server.lua:18: bad argument @ 'getvehiclecolor' function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local c1 = nil local c2 = nil local c1,c2,c3,c4 = getVehicleColor (getPedOccupiedVehicle(source)) setAccountData (playeraccount, "carcolor1", c1) setAccountData (playeraccount, "carcolor2", c2) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) function onPlayerWasted ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local c1 = nil local c2 = nil local c1,c2,c3,c4 = getVehicleColor (getPedOccupiedVehicle(source)) setAccountData (playeraccount, "carcolor1", c1) setAccountData (playeraccount, "carcolor2", c2) end end addEventHandler ( "onPlayerWasted", getRootElement ( ), onPlayerWasted ) function onPlayerSpawn ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local c1 = nil local c2 = nil local c1 = getAccountData ( playeraccount, "carcolor1" ) local c2 = getAccountData ( playeraccount, "carcolor2" ) if c1 and c2 then veh = getPedOccupiedVehicle(source) if veh then setVehicleColor ( veh, c1, c2, 0, 0 ) end end end end addEventHandler ( "onPlayerSpawn", getRootElement ( ), onPlayerSpawn )
kevin11 Posted June 22, 2010 Author Posted June 22, 2010 can anyone tell me whats wrong because i really dont see it
LonelyRoad Posted June 22, 2010 Posted June 22, 2010 getPedOccupiedVehicle doesn't know what source is, you, for that matter, the entire function doesn't know what source is. You need to do something like local player = getPedOccupiedVehicle(sourcePlayer) getVehicleColor(player) or function SetCarColor(sourcePlayer) -- Or GetCarColor, depends what the function is doing. getVehicleColor(sourcePlayer) You need to study the basics of creating functions and depending on what your code is doing is how you know what arguments to give to the function.
Castillo Posted June 22, 2010 Posted June 22, 2010 Uniqu3, Im not 14 years old, but yes i love MGS series . i had to put this nick cause i cant find another one San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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