No errors , no warnings - just not working
#1

Hello guys!

I made a script ,that spawns player in the bed if he was dead and etc.

And everything is working fine ,but it doesnt send me to bed and it doesnt activate the animation.

Take a look:

pawn Код:
stock PlaceToHospitalBed(playerid)
{
    new bool: full = true;
    for (new i; i != sizeof (LigoninesLovos); ++i)
    {
        if (LigoninesLovos[i][LL_taken] == false)
        {
            full = false;
        }
    }
    if (full)
    {
        SetPlayerPos(playerid,-202.3200,-1761.7898,675.7687);
        SendClientMessage(playerid,CHATCOLOR_RED,"Palatose nera vietu todel buvai greit pagydytas ant operacinio stalo.");
    }
    else
    {
        new Random, count;
        Random = random(sizeof (LigoninesLovos));
        if (LigoninesLovos[Random][LL_taken] == false)
        {
            SetPlayerInterior(playerid,3);
            SetPlayerPos(playerid, LigoninesLovos[Random][LL_pos][0], LigoninesLovos[Random][LL_pos][1], LigoninesLovos[Random][LL_pos][2]);
            SetPlayerFacingAngle(playerid, LigoninesLovos[Random][LL_pos][3]);
            ApplyAnimation(playerid,"CRACK","crckdeth2",4.1, 0, 1, 1, 1, 0);
            TogglePlayerSpectating(playerid, 1);
            TogglePlayerControllable(playerid, 0);
            InterpolateCameraPos(playerid, -200.499435, -1758.981567, 677.898132, -200.831359, -1772.208251, 677.901367, 20000);
            InterpolateCameraLookAt(playerid, -198.193222, -1763.108764, 676.270874, -198.342041, -1768.232177, 676.171081, 20000);
            SendClientMessage(playerid, CHATCOLOR_RED, "Siek tiek turesi palaukti kol pagysi!");
            LigoninesLovos[Random][LL_taken] = true;
            count++;
        }
        if(count == sizeof(LigoninesLovos))
        {
            full = true;
        }
    }
    return 1;
}
Reply
#2

Help anyone?
Reply
#3

You don't need to create a random place, just pick the first empty slot the first loop finds and break the loop in that case.


Try this:
pawn Код:
stock PlaceToHospitalBed(playerid)
{
    new bool: full = true;
    for (new i; i < sizeof (LigoninesLovos); ++i)
    {
        if (LigoninesLovos[i][LL_taken] == false)
        {
            full = false;
            SetPlayerInterior(playerid,3);
            SetPlayerPos(playerid, LigoninesLovos[Random][LL_pos][0], LigoninesLovos[Random][LL_pos][1], LigoninesLovos[Random][LL_pos][2]);
            SetPlayerFacingAngle(playerid, LigoninesLovos[Random][LL_pos][3]);
            ApplyAnimation(playerid,"CRACK","crckdeth2",4.1, 0, 1, 1, 1, 0);
            TogglePlayerSpectating(playerid, 1);
            TogglePlayerControllable(playerid, 0);
            InterpolateCameraPos(playerid, -200.499435, -1758.981567, 677.898132, -200.831359, -1772.208251, 677.901367, 20000);
            InterpolateCameraLookAt(playerid, -198.193222, -1763.108764, 676.270874, -198.342041, -1768.232177, 676.171081, 20000);
            SendClientMessage(playerid, CHATCOLOR_RED, "Siek tiek turesi palaukti kol pagysi!");
            LigoninesLovos[i][LL_taken] = true;
            break;
        }
    }
    if (full)
    {
        SetPlayerPos(playerid,-202.3200,-1761.7898,675.7687);
        SendClientMessage(playerid,CHATCOLOR_RED,"Palatose nera vietu todel buvai greit pagydytas ant operacinio stalo.");
    }
    return 1;
}
Reply
#4

I have 6 beds and lets say your code will make them taken if one player dies ....This is bad.
Reply
#5

Have you tested it?

That break-function that i've put in my code stops the loop if an empty bed is found. it won't fill all beds.
Reply
#6

Nope , its not working.
Reply
#7

Does the function itself acutally gets called?
Try to debug it by puting some prints on different places in the funtion, then run the server, send yourself to the hospital, quit sa-mp, check the serverlog and see how the funtion handled.
Did the function get called? Did it start the loop, did it found an empty bed or not?

Example:

pawn Код:
stock PlaceToHospitalBed(playerid)
{
    print("PlaceHospitalBed called");
    new bool: full = true;
    for (new i; i < sizeof (LigoninesLovos); ++i)
    {
        printf("Loop #%d - BedTaken: %d", i, LigoninesLovos[i][LL_taken]);
        if (LigoninesLovos[i][LL_taken] == false)
        {
            print("Empty bed found");
            full = false;
            SetPlayerInterior(playerid,3);
            SetPlayerPos(playerid, LigoninesLovos[Random][LL_pos][0], LigoninesLovos[Random][LL_pos][1], LigoninesLovos[Random][LL_pos][2]);
            SetPlayerFacingAngle(playerid, LigoninesLovos[Random][LL_pos][3]);
            ApplyAnimation(playerid,"CRACK","crckdeth2",4.1, 0, 1, 1, 1, 0);
            TogglePlayerSpectating(playerid, 1);
            TogglePlayerControllable(playerid, 0);
            InterpolateCameraPos(playerid, -200.499435, -1758.981567, 677.898132, -200.831359, -1772.208251, 677.901367, 20000);
            InterpolateCameraLookAt(playerid, -198.193222, -1763.108764, 676.270874, -198.342041, -1768.232177, 676.171081, 20000);
            SendClientMessage(playerid, CHATCOLOR_RED, "Siek tiek turesi palaukti kol pagysi!");
            LigoninesLovos[i][LL_taken] = true;
            print("Player send to hospital");
            break;
        }
    }
    print("Loop finished");
    if (full)
    {
        print("All beds are full");
        SetPlayerPos(playerid,-202.3200,-1761.7898,675.7687);
        SendClientMessage(playerid,CHATCOLOR_RED,"Palatose nera vietu todel buvai greit pagydytas ant operacinio stalo.");
    }
    print("End of function");
    return 1;
}
Reply
#8

Every parts get called.But it doesnt place player in the bed.

Camera does interpolate, SCM working ,GameText working
Reply
#9

Oh wait, the SetPlayerPos & SetPlayerFacingAngle have to be changed too:

pawn Код:
SetPlayerPos(playerid, LigoninesLovos[i][LL_pos][0], LigoninesLovos[i][LL_pos][1], LigoninesLovos[i][LL_pos][2]);
SetPlayerFacingAngle(playerid, LigoninesLovos[i][LL_pos][3]);
Reply
#10

Yeah i know , i changed it because i was getting error , but as i said still ,this part of code is not working...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)