SA-MP Forums Archive
Help about SWAT Rope bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help about SWAT Rope bug (/showthread.php?tid=597455)



Help about SWAT Rope bug - Bumie - 31.12.2015

In this script, when two players use command duday at one time, after them finished, there're some bug of object. The object of the rope will appear in their position and it's not destroyed (I think the player who use this command later will having bug object of rope). How to fix it.
When only one player use this command, it's ok, no error. But when more than 2 player, there some bug of later people.
Код HTML:
new rope[58];
CMD:duday(playerid,params[])
{
    new Float:X, Float:Y, Float:Z, Float:Angle, Float:health;

    GetPlayerHealth(playerid,health);
    SetPVarFloat(playerid, "pPreGodHealth", health);
    SetPlayerHealth(playerid, 0x7FB00000);
   
    GetPlayerPos(playerid, X, Y, Z);
    GetXYInFrontOfPlayer(playerid, X, Y, 2.0);
   
    SetPlayerPos(playerid, X, Y, Z);
    SetPVarInt(playerid,"rappelling",1);
    PlayerInfo[playerid][pRope] -= 2;
    GameTextForPlayer(playerid, "~B~S.W.A.T ~R~Du day", 5000, 1);
    rope[1] = CreateDynamicObject(19089, X, Y, Z+5, 0, 0, Angle);
    rope[2] = CreateDynamicObject(19089, X, Y, Z+3, 0, 0, Angle);
    rope[3] = CreateDynamicObject(19089, X, Y, Z+1, 0, 0, Angle);
    rope[4] = CreateDynamicObject(19089, X, Y, Z-2, 0, 0, Angle);
    rope[5] = CreateDynamicObject(19089, X, Y, Z-5, 0, 0, Angle);
    rope[6] = CreateDynamicObject(19089, X, Y, Z-7, 0, 0, Angle);
    rope[7] = CreateDynamicObject(19089, X, Y, Z-9, 0, 0, Angle);
    rope[8] = CreateDynamicObject(19089, X, Y, Z-10, 0, 0, Angle);
    rope[9] = CreateDynamicObject(19089, X, Y, Z-12, 0, 0, Angle);
    rope[10] = CreateDynamicObject(19089, X, Y, Z-17, 0, 0, Angle);
    rope[11] = CreateDynamicObject(19089, X, Y, Z-25, 0, 0, Angle);
    rope[12] = CreateDynamicObject(19089, X, Y, Z-28, 0, 0, Angle);
    rope[13] = CreateDynamicObject(19089, X, Y, Z-31, 0, 0, Angle);
    rope[14] = CreateDynamicObject(19089, X, Y, Z-34, 0, 0, Angle);
    rope[15] = CreateDynamicObject(19089, X, Y, Z-38, 0, 0, Angle);
    rope[16] = CreateDynamicObject(19089, X, Y, Z-41, 0, 0, Angle);
    rope[17] = CreateDynamicObject(19089, X, Y, Z-45, 0, 0, Angle);
    rope[18] = CreateDynamicObject(19089, X, Y, Z-49, 0, 0, Angle);
    rope[19] = CreateDynamicObject(19089, X, Y, Z-51, 0, 0, Angle);
    rope[20] = CreateDynamicObject(19089, X, Y, Z-57, 0, 0, Angle);
    rope[21] = CreateDynamicObject(19089, X, Y, Z-61, 0, 0, Angle);
    rope[22] = CreateDynamicObject(19089, X, Y, Z-65, 0, 0, Angle);
    rope[23] = CreateDynamicObject(19089, X, Y, Z-69, 0, 0, Angle);
    rope[24] = CreateDynamicObject(19089, X, Y, Z-73, 0, 0, Angle);
    rope[25] = CreateDynamicObject(19089, X, Y, Z-77, 0, 0, Angle);
    rope[26] = CreateDynamicObject(19089, X, Y, Z-80, 0, 0, Angle);
    rope[27] = CreateDynamicObject(19089, X, Y, Z-85, 0, 0, Angle);
    rope[28] = CreateDynamicObject(19089, X, Y, Z-89, 0, 0, Angle);
    rope[29] = CreateDynamicObject(19089, X, Y, Z-90, 0, 0, Angle);
    rope[30] = CreateDynamicObject(19089, X, Y, Z-95, 0, 0, Angle);
    rope[31] = CreateDynamicObject(19089, X, Y, Z-87, 0, 0, Angle);
    rope[32] = CreateDynamicObject(19089, X, Y, Z-100, 0, 0, Angle);
    rope[33] = CreateDynamicObject(19089, X, Y, Z-105, 0, 0, Angle);
    rope[34] = CreateDynamicObject(19089, X, Y, Z-110, 0, 0, Angle);
    rope[35] = CreateDynamicObject(19089, X, Y, Z-115, 0, 0, Angle);
    rope[36] = CreateDynamicObject(19089, X, Y, Z-120, 0, 0, Angle);
    rope[37] = CreateDynamicObject(19089, X, Y, Z-125, 0, 0, Angle);
    rope[38] = CreateDynamicObject(19089, X, Y, Z-130, 0, 0, Angle);
    rope[39] = CreateDynamicObject(19089, X, Y, Z-135, 0, 0, Angle);
    rope[40] = CreateDynamicObject(19089, X, Y, Z-140, 0, 0, Angle);
    rope[41] = CreateDynamicObject(19089, X, Y, Z-145, 0, 0, Angle);
    rope[42] = CreateDynamicObject(19089, X, Y, Z-150, 0, 0, Angle);
    rope[43] = CreateDynamicObject(19089, X, Y, Z-155, 0, 0, Angle);
    rope[45] = CreateDynamicObject(19089, X, Y, Z-160, 0, 0, Angle);
    rope[46] = CreateDynamicObject(19089, X, Y, Z-165, 0, 0, Angle);
    rope[47] = CreateDynamicObject(19089, X, Y, Z-170, 0, 0, Angle);
    rope[48] = CreateDynamicObject(19089, X, Y, Z-175, 0, 0, Angle);
    rope[49] = CreateDynamicObject(19089, X, Y, Z-180, 0, 0, Angle);
    rope[50] = CreateDynamicObject(19089, X, Y, Z-185, 0, 0, Angle);
    rope[51] = CreateDynamicObject(19089, X, Y, Z-190, 0, 0, Angle);
    rope[52] = CreateDynamicObject(19089, X, Y, Z-195, 0, 0, Angle);
    rope[53] = CreateDynamicObject(19089, X, Y, Z-200, 0, 0, Angle);
    rope[54] = CreateDynamicObject(19089, X, Y, Z-205, 0, 0, Angle);
    rope[55] = CreateDynamicObject(19089, X, Y, Z-210, 0, 0, Angle);
    rope[56] = CreateDynamicObject(19089, X, Y, Z-215, 0, 0, Angle);
    rope[57] = CreateDynamicObject(19089, X, Y, Z-220, 0, 0, Angle);
    ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,0);
    return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:health;
    if((newkeys && KEY_SPRINT) && GetPVarInt(playerid, "rappelling") == 1)
    {
        for(new i = 0 ;i < 58; i++)
        {
           DestroyDynamicObject(rope[i]);
        }
        health = GetPVarFloat(playerid, "pPreGodHealth");
        SetPlayerHealth(playerid,health);
        DeletePVar(playerid, "pPreGodHealth");
        SetPVarInt(playerid,"rappelling",0);
        ClearAnimations(playerid);
        return 1;
    }
}