SetPlayerVelocity
#1

Hey, im making a script which sets ur velocity to a certain amount, but the z part wont work, ive tried a lot of ways, but if i set 50 or 5 at the vz
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
        new vx,vy,vz;
        GetPlayerVelocity(playerid,Float:vx,Float:vy,Float:vz);
        SetPlayerVelocity(playerid,vx + 0.5,vy - 0.7 ,vz + 0.5);
    }
Reply
#2

pawn Код:
new vx,vy,vz;
Must be
pawn Код:
new Float:vx,Float:vy,Float:vz;
Don't know why Z isn't working...
Reply
#3

You have to init the variables as Floats, meaning, add the Float: tag in front of the variables already in the "new ..." line, not in the line when you get the velocity. Else they will just be integers, and they are not compatible with the velocity stuff.

pawn Код:
new Float:vx, Float:vy, Float:vz;
Reply
#4

@ Mauzen, the vx and the vy part works perfect.

Just not the Z
Reply
#5

Bump? Sorry just need a solution.
Reply
#6

Just put new Float:vx, Float:vy, Float:vz;
Reply
#7

pawn Код:
if(newkeys == KEY_SECONDARY_ATTACK)
    {
        new Float:vx,Float:vy,Float:vz;
        GetPlayerVelocity(playerid,vx,vy,vz);
        SetPlayerVelocity(playerid,vx + 0.5,vy - 0.7 ,vz + 0.5);
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)