SWAT Rope
#1

So I was trying to modify Trooper's old code with the SWAT rope to allow landing on mapped objects and without mapandreas.

I was trying to achieve this using velocity: set player velocity to a negative, setplayerhealth to a large value to prevent death, create rope objects, then let the player go down, onplayerupdate will check the z velocity and if it's 0, it'll stop the rappel anim, set the player's health back to the old hp, destroy objects.

Here's my code:

/rope command's contents:

Код:
				if(!PlayerInfo[playerid][pRoped] && !GetPlayerVehicleSeat(playerid))
				{
				    new Float:pls_pos[5], Float:hp;
					GetPlayerPos(playerid,pls_pos[0],pls_pos[1],pls_pos[2]);
					GetPlayerHealth(playerid, hp);
					SetPVarFloat(playerid, "RopeOldHealth", hp);
					pls_pos[4] = floatsub(pls_pos[2],pls_pos[3]);
					SetPlayerArmedWeapon(playerid, 0);
					SetPlayerHealth(playerid, 500.0);
					SetPlayerPos(playerid,pls_pos[0],pls_pos[1],pls_pos[2] - 1.0);
					SetPlayerVelocity(playerid,0,0,-0.02);
					for(new cre=0;cre<=pls_pos[2];cre++)
					{
					    PlayerInfo[playerid][pRopes][cre] = CreateDynamicObject(3004,pls_pos[0],pls_pos[1],floatadd(pls_pos[3],cre),87.640026855469,342.13500976563, 350.07507324219);
					}
		 	 		for(new rep=0;rep!=10;rep++) ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,0);
					PlayerInfo[playerid][pRoped] = 1;
				}
OnPlayerUpdate:

Код:
	if(PlayerInfo[playerid][pRoped] == 1)
	{
		new Float:VelocityX, Float:VelocityY, Float:VelocityZ;
		GetPlayerVelocity(playerid, VelocityX, VelocityY, VelocityZ);
		if(VelocityZ == 0.0)
		{
  			for(new destr4=0;destr4<=50;destr4++)
			{
			    DestroyDynamicObject(PlayerInfo[playerid][pRopes][destr4]);
			}
			TogglePlayerControllable(playerid,true);
	        SetPlayerHealth(playerid, GetPVarFloat(playerid, "RopeOldHealth"));
	        PlayerInfo[playerid][pRoped] = 0;
	        ClearAnimations(playerid);
		}
		else
		{
			ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,0);
		}
	}
It doesn't stop, even when my velocity is 0 (standing still).

Any help?

EDIT: Indention is fucked, w/e.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)