Jump to content

Name a car depending on playername


Recommended Posts

I am already spawning cars with this code:

local Car2 = createVehicle ( 541, x, y, z) 

but I want do make the name of the car dependend on the player who spawns the car.

How can I name the car so that if player 1 Spawns it it is called car_player1 and if player 2 spawans it it is called car_player2

Link to comment

But I want to do it automatically according to the playername, so I can't use a predefined table. Also I want to name the cars car_playername, which means I would have to merge the predefined expression "car_" with the dynamic expression "playername" that is received by getPlayerName()

Link to comment
aCars = { } 
  
-- stuff 
  
local pPlayer = getPlayerName ( elem ); 
aCars['car_' .. pPlayer] = createVehicle ( 411, x, y, z ); 
  
  
--[[ 
  
How will be the table after insert: 
  
aCars = 
{ 
    ['car_playername'] = pointer to created vehicle; 
} 
  
]]-- 
  

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