Plantjen Posted August 14, 2010 Share Posted August 14, 2010 I'm starting to learn a little bit of lua, but there's some very basic thingy that i just can't get right. I have the following code in my server file that i use to lock/unlock cars. This code is from the speedometer(https://community.multitheftauto.com/index.html?p=resources&s=details&id=5) resource by 50p function lock_unlockDoor( player ) local playername = getPlayerName ( player ) local veh = getPedOccupiedVehicle( player ) local lock = isVehicleLocked( veh ) if veh and lock == false then setVehicleLocked( veh, true ) outputChatBox("Car locked",playername,255,255,0,255) elseif veh and lock == true then setVehicleLocked( veh, false ) outputChatBox("Car unlocked",playername,255,255,0,255) end end I wanted to change it so that only the player that locks the car gets the message 'Car locked' or 'Car unlocked'. Currently if i lock a car, the message is shown to every player in the server. What have i done wrong? Any help will be very much appreciated Link to comment
The_Ex Posted August 14, 2010 Share Posted August 14, 2010 You output message to player NOT his name. function lock_unlockDoor( player ) local veh = getPedOccupiedVehicle( player ) local lock = isVehicleLocked( veh ) if veh and lock == false then setVehicleLocked( veh, true ) outputChatBox("Car locked",player,255,255,0,255) elseif veh and lock == true then setVehicleLocked( veh, false ) outputChatBox("Car unlocked",player,255,255,0,255) end end Link to comment
Plantjen Posted August 14, 2010 Author Share Posted August 14, 2010 Though it seems very strange to me it does work! Thank you a lot, now i can also make progress on other scripts Link to comment
dzek (varez) Posted August 14, 2010 Share Posted August 14, 2010 after you will learn something about elements - it wont be strange anymore. btw: wiki clearly says: player element, not player name 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