stock CreateVelocity [Help]
#1

Hello every one, i would like to know why when i pass on velocity it make me slow(not what type in the command).
the command is /velocity speed speed:y speed:z
Here is my code
pawn Код:
//at the top
#define MAX_VELOCITY 500
#define UPDATE_PICKUPS_TIMER 1
new VelocityCounter;
enum vinfo
    {
    Float:Pos[3],
    Float:V[3]
    };
new VELOCITY[MAX_VELOCITY][vinfo];
pawn Код:
public OnGameModeInit()
{
SetTimer("Velocity",UPDATE_PICKUPS_TIMER,true);
return 1;
}
pawn Код:
forward Velocity();
public Velocity()
 {
    for(new i = 0; i < MAX_PLAYERS; i++)
        {
        if(IsPlayerConnected(i))
                {
                    for(new x; x<VelocityCounter; x++)
                    {
                    if(IsPlayerInRangeOfPoint(i,1,VELOCITY[x][Pos][0],VELOCITY[x][Pos][1],VELOCITY[x][Pos][2]))
                    {
                        if(IsPlayerInAnyVehicle(i))
                            {
                                new Float:X,Float:Y,Float:Z;
                                GetVehicleVelocity(GetPlayerVehicleID(i),X,Y,Z);
                                SetVehicleVelocity(GetPlayerVehicleID(i),X*VELOCITY[x][V][0],Y*VELOCITY[x][V][1],Z*VELOCITY[x][V][2]);
                            }
                    }
                    }
                }
        }
    }
and Here is the command for Creating velocity
pawn Код:
CMD:velocity(playerid,params[])
    {
    new Float:v[3];
    if(sscanf(params, "ddd", v[0],v[1],v[2])) return SendClientMessage(playerid, 0xFF0000AA, "Command Usage: /velocity [x:speed] [y:speed] [z:speed]");
    new Float:PoS[3];
    GetPlayerPos(playerid,PoS[0],PoS[1],PoS[2]);
    CreateVelocity(PoS[0],PoS[1],PoS[2],v[0],v[1],v[2]);
    SendClientMessage(playerid,-1,"Velocity added");
    return 1;
    }
pawn Код:
stock CreateVelocity(Float:x,Float:y,Float:z,Float:vx,Float:vy,Float:vz)
    {
                    Create3DTextLabel("[Velocity]",0xDEEE20FF,x,y,z,100,0);
                    VELOCITY[VelocityCounter][Pos][0] = x;
                    VELOCITY[VelocityCounter][Pos][1] = y;
                    VELOCITY[VelocityCounter][Pos][2] = z;
                    VELOCITY[VelocityCounter][V][0] = vx;
                    VELOCITY[VelocityCounter][V][1] = vy;
                    VELOCITY[VelocityCounter][V][2] = vz;
                    VelocityCounter++;
                    return 1;
    }
Thanks.
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
You've not actually posted your "CreateVelocity" function.
Ah, added
Quote:
Originally Posted by ******
Посмотреть сообщение
why are you using arrays to hold three variables?
That wont make different i gusse ?
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
You've not actually posted your "CreateVelocity" function. And why are you using arrays to hold three variables?
Quote:
Originally Posted by ******
Посмотреть сообщение
No, but I've just spotted the problem - you use "d" not "f" in "sscanf". Try "extract":

pawn Код:
extract params -> new Float:vx, Float:vy, Float:vz; else return SendClientMessage(playerid, 0xFF0000AA, "Command Usage: /velocity [x:speed] [y:speed] [z:speed]");
Vastly reduces bugs due to incorrect specifiers by removing the specifiers. You can also still use arrays:

pawn Код:
extract params -> new Float:v[3]; else return SendClientMessage(playerid, 0xFF0000AA, "Command Usage: /velocity [x:speed] [y:speed] [z:speed]");
Aha.
Thanks its work now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)