xxldoener Posted June 2, 2012 Share Posted June 2, 2012 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
Anderl Posted June 2, 2012 Share Posted June 2, 2012 You can do it with tables. aCars = { ['xxldoener'] = createVehicle ( 541, x, y, z ), ['Draken'] = createVehicle ( 541, x, y, z ); } Link to comment
xxldoener Posted June 2, 2012 Author Share Posted June 2, 2012 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
Anderl Posted June 2, 2012 Share Posted June 2, 2012 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
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