Jump to content

Very basic question about outputting to one player


Plantjen

Recommended Posts

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

Link to comment

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

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...