Jump to content

Very basic question about outputting to one player


Plantjen

Recommended Posts

Posted

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 :D

Posted

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

MTASA.LV - Latvian MTA Community

Posted

after you will learn something about elements - it wont be strange anymore.

btw: wiki clearly says: player element, not player name :)

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)!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...