SA-MP Forums Archive
What's wrong with this code? (won't freeze the player) - 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: What's wrong with this code? (won't freeze the player) (/showthread.php?tid=353274)



What's wrong with this code? (won't freeze the player) - Makaveli93 - 22.06.2012

Instead of placing my character into a sliding animation and then after hitting "2" again freezing him, he just falls down and doesn't gets freezed (and dies).

This is to start sliding or release the rope code.
pawn Код:
if(PRESSED(KEY_SUBMISSION))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 497)
            {
                new vid = GetPlayerVehicleID(playerid);
                if(IsPlayerUsingRopes[playerid])
                {
                    IsPlayerUsingRopes[playerid] = false;
                    TogglePlayerControllable(playerid, 0);
                    SetTimerEx("UnfreezePlayer", 500, false, "i", playerid);
                    return 1;
                }
                for(new ply=0;ply<MAX_PLAYERS;ply++) // check if seat id 3 is taken
                {
                    if(ply != playerid)
                    {
                        if(GetPlayerVehicleSeat(ply) == 3) return SendClientMessage(playerid, COLOR_ORANGE, "[ERROR:] Wait for the first person to rope down ((seat ID 3)).");
                    }
                }  
                IsPlayerUsingRopes[playerid] = true;
                RemovePlayerFromVehicle(playerid);
                PutPlayerInVehicle(playerid, vid, 3);
                new Float:x11[3];
                GetPlayerPos(playerid, x11[0], x11[1], x11[2]);
                new Float:carzangle;
                GetVehicleZAngle(vid, carzangle);
                RemovePlayerFromVehicle(playerid);
                SetPlayerPos(playerid, x11[0],x11[1],x11[2] - 0.8);
                SetPlayerFacingAngle(playerid, carzangle - 90);
                GetXYBehindPlayer(playerid, x11[0], x11[1], 0.3);
                SetPlayerPos(playerid, x11[0],x11[1],x11[2] - 0.8);
                SetPlayerFacingAngle(playerid, carzangle - 90);
                ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,1);
                ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,1);
                ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,1);
                return 1;
            }
        }
    }

EDIT: These are some errors I found in my server log just now

Код:
[20:58:23] [debug] #0  00108a9c in OnPlayerKeyStateChange () from vhrp.amx
[20:58:23] [debug] Backtrace (most recent call first):
[20:58:23] [debug]   Accessing element at index 255 past array upper bound 9
[20:58:23] [debug] Run time error 4: "Array index out of bounds"
[20:58:21] [debug] #0  00108a9c in OnPlayerKeyStateChange () from vhrp.amx
[20:58:21] [debug] Backtrace (most recent call first):
[20:58:21] [debug]   Accessing element at index 255 past array upper bound 9
[20:58:21] [debug] Run time error 4: "Array index out of bounds"
[20:58:20] [debug] #0  00108a9c in OnPlayerKeyStateChange () from vhrp.amx
[20:58:20] [debug] Backtrace (most recent call first):
[20:58:20] [debug]   Accessing element at index 255 past array upper bound 9
[20:58:20] [debug] Run time error 4: "Array index out of bounds"
[20:58:16] [debug] #0  00108a9c in OnPlayerKeyStateChange () from vhrp.amx
[20:58:16] [debug] Backtrace (most recent call first):
[20:58:16] [debug]   Accessing element at index 255 past array upper bound 9
[20:58:16] [debug] Run time error 4: "Array index out of bounds"
[20:58:16] [join] Andrej_Ivanov has joined the server (4:78.0.102.220)
[20:58:16] Incoming connection: 78.0.102.220:49228
[20:58:13] [debug] #0  00108a9c in OnPlayerKeyStateChange () from vhrp.amx
[20:58:13] [debug] Backtrace (most recent call first):
[20:58:13] [debug]   Accessing element at index 255 past array upper bound 9
[20:58:13] [debug] Run time error 4: "Array index out of bounds"
[20:58:11] [debug] #0  00108a9c in OnPlayerKeyStateChange () from vhrp.amx
[20:58:11] [debug] Backtrace (most recent call first):
[20:58:11] [debug]   Accessing element at index 255 past array upper bound 9
[20:58:11] [debug] Run time error 4: "Array index out of bounds"
[20:57:53] [debug] #0  00108a9c in OnPlayerKeyStateChange () from vhrp.amx
[20:57:53] [debug] Backtrace (most recent call first):
[20:57:53] [debug]   Accessing element at index 255 past array upper bound 9
[20:57:53] [debug] Run time error 4: "Array index out of bounds"
[20:57:52] [debug] #0  00108a9c in OnPlayerKeyStateChange () from vhrp.amx
[20:57:52] [debug] Backtrace (most recent call first):
[20:57:52] [debug]   Accessing element at index 255 past array upper bound 9
[20:57:52] [debug] Run time error 4: "Array index out of bounds"
[20:57:51] [debug] #0  00108a9c in OnPlayerKeyStateChange () from vhrp.amx
[20:57:51] [debug] Backtrace (most recent call first):
[20:57:51] [debug]   Accessing element at index 255 past array upper bound 9
[20:57:51] [debug] Run time error 4: "Array index out of bounds"
[20:57:50] [debug] #0  00108a9c in OnPlayerKeyStateChange () from vhrp.amx
[20:57:50] [debug] Backtrace (most recent call first):
[20:57:50] [debug]   Accessing element at index 255 past array upper bound 9
[20:57:50] [debug] Run time error 4: "Array index out of bounds"
[20:57:34] [debug] #0  00108a9c in OnPlayerKeyStateChange () from vhrp.amx
[20:57:34] [debug] Backtrace (most recent call first):
[20:57:34] [debug]   Accessing element at index 255 past array upper bound 9
[20:57:34] [debug] Run time error 4: "Array index out of bounds"



Re: What's wrong with this code? (won't freeze the player) - BlackStrike - 22.06.2012

TogglePlayerControllable(playerid, 0); should be TogglePlayerControllable(playerid, false);