Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - tucson913

#1
Scripting Help / client.player.position
December 21, 2024, 11:05:50 AM
Hi all!

I have problem with the player position.

I wrote a simple vehicle spawn command and I get this error message:
QuoteTypeError: client.player is null

The client.player exists only on client side? Or how can I get the player position?
Thank you!

Code:
addEventHandler('OnPlayerCommand', (event, client, command, parameters) => {

    console.log(`(Command) ${client.name} has used the command '/${command} ${parameters}'.`);
   
      switch(command){
        case "v":
            case "veh":
                case "vehicle":
                    var veh = gta.createVehicle(parseInt(parameters), client.player.position);
                    addToWorld(veh);
                    client.player.warpIntoVehicle(veh, 0);
        break;

        default:
            message("UNK CMD");
        break;
      }
});