Move object Command
#1

Hello i've this command to move object in game

PHP код:
CMD:mo(playerid,params[])
{
  new 
Float:xFloat:yFloat:zFloat:speed;
  if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,red,"Command not found! Type /cmds");
  if(
sscanf(params"ffff",x,y,z,speed)) return SendClientMessage(playerid,red,"Move object: /x /bla /bla /bla");
  
MoveObject(ObjectID,x,y,z,speed,0,0,0);
  return 
1;

its work fine if i type the position like this 1363.6510 -1279.8331 13.5469
but if i type it like this 1363.6510,-1279.8331,13.5469 its not work and that is my problem

sorry for my english
Reply
#2

To use commas you need to split it. When there are spaces in a command that is considered a parameter. In this instance you have 4 parameters: coordinates and speed.

So yeah you would have to first get the input parameter that contains commas and split it. If it all contains commas but no spaces, that will then be 1 parameter and a string. So you would also have to afterwards convert it to a float. I would elaborate further but I'm on mobile.

What he said below is exactly how to do it.
Reply
#3

Try it:
Код:
if(sscanf(params, "p<,>ffff",x,y,z,speed))
Reply
#4

Thank you both
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)