Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Magnetic object SetPlayerVelocity?

$
0
0
So I've wrote up some messy code but I don't understand how SetPlayerVelocity works

PHP Code:

#include <a_samp>
#include <foreach>
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

new 
Wreckball[MAX_PLAYERS];
new 
CountWreck[MAX_PLAYERS];
new 
Float:MoveToTargetX[MAX_PLAYERS];
new 
Float:MoveToTargetY[MAX_PLAYERS];
new 
Float:MoveToTargetZ[MAX_PLAYERS];
public 
OnFilterScriptExit()
{
    for(new 
0MAX_PLAYERSo++)
    {
        
DestroyObject(Wreckball[o]);
    }
    return 
1;
}


public 
OnPlayerDisconnect(playerid)
{
    
DestroyObject(Wreckball[playerid]);
    return 
1;
}

public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
PRESSED(KEY_FIRE))
    {
        if(
CountWreck[playerid] == 0)
        {
            
CountWreck[playerid] = 1;
            new 
Float:XFloat:YFloat:Z;
            
GetPlayerPos(playeridXYZ);
            
Wreckball[playerid] = CreateObject(18845XYZ+201800300);
            
GetPlayerCameraLookAt(playeridXYZ);
            
MoveToTargetX[playerid] = X;
            
MoveToTargetY[playerid] = Y;
            
MoveToTargetZ[playerid] = Z;
            
SetTimerEx("MoveFuckingObject"7500"i"playerid);
        }
        return 
1;
    }
    return 
1;
}

forward MoveFuckingObject(playerid);
public 
MoveFuckingObject(playerid)
{
        
MoveObject(Wreckball[playerid], MoveToTargetX[playerid], MoveToTargetY[playerid], MoveToTargetZ[playerid], 100.001800);
     
//    foreach(Player,i)
         
{
     
//    if(team[i] == TEAM_ZOMBIE)
               // GetPlayerPos(i, X, Y, Z);
                //GetXYInFrontOfPlayer(i, X, Y, 0.2);
               // SetPlayerVelocity(i, 0.0, 0.0, 0.2);
                
}
    return 
1;
}


stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2Float:distance)
{
    new 
Float:a;
    
GetPlayerPos(playeridx2y2a);
    
GetPlayerFacingAngle(playerida);
    
x2 += (distance floatsin(-adegrees));
    
y2 += (distance floatcos(-adegrees));
}

stock GetXYBackOfPlayer(const playerid, &Float:x, &Float:y, const Float:distance)
{
    new 
Float:a;
    
GetPlayerPos(playeridxya);
    
GetPlayerFacingAngle(playerida);
    
-= (distance floatsin(-adegrees));
    
-= (distance floatcos(-adegrees));
}

stock GetXYBackOfObject(const playerid, &Float:x, &Float:y, const Float:distance)
{
    new 
Float:a;
    
GetPlayerFacingAngle(playerida);
    
-= (distance floatsin(-adegrees));
    
-= (distance floatcos(-adegrees));
}

stock GetXYRightOfPlayer(playerid, &Float:X, &Float:YFloat:distance)
{
    new 
Float:Angle;
    
GetPlayerFacingAngle(playeridAngle); Angle -= 90.0;
    
+= floatmul(floatsin(-Angledegrees), distance);
    
+= floatmul(floatcos(-Angledegrees), distance);
}

GetPlayerCameraLookAt(playerid, &Float:X, &Float:Y, &Float:Z)
{
    new 
Float:Destination[3], Float:Camera[3], Float:Vector[3];
    
GetPlayerPos(playeridDestination[0], Destination[1], Destination[2]);
    
GetPlayerCameraPos(playeridCamera[0], Camera[1], Camera[2]);
    
GetPlayerCameraFrontVector(playeridVector[0], Vector[1], Vector[2]);
    new 
FloatposAngle atan2(floatsub(Destination[1],Camera[1]),floatsub(Destination[0],Camera[0]));
    if(
posAngle 360posAngle-=360posAngle+=270posAngle *= -1;
    
Destination[0] += 50.0 floatsin(posAngledegrees);
    
Destination[1] += 50.0 floatcos(posAngledegrees);
    new 
Float:dis floatsqroot((Camera[0] - Destination[0]) * (Camera[0] - Destination[0]) + (Camera[1] - Destination[1]) * (Camera[1] - Destination[1]) + (Camera[2] - Destination[2]) * (Camera[2] - Destination[2]));
    
Vector[0] * dis Camera[0]; Vector[1] * dis Camera[1];       Vector[2] * dis Camera[2];


Basically the player shoots this object then the other players should be dragged into the object with SetPlayerVelocity not SetPlayerPos
what I've tried (KEWL LOL)
PHP Code:

forward MoveFuckingObject(playerid);
public 
MoveFuckingObject(playerid)
{
        
MoveObject(Wreckball[playerid], MoveToTargetX[playerid], MoveToTargetY[playerid], MoveToTargetZ[playerid], 100.001800);
     
//    foreach(Player,i)
         
{
     
//    if(team[i] == TEAM_ZOMBIE)
               // GetPlayerPos(i, X, Y, Z);
                //GetXYInFrontOfPlayer(i, X, Y, 0.2);
               // SetPlayerVelocity(i, 0.0, 0.0, 0.2);
                
}
    return 
1;


Would appreciate any help, thanks.

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>