SA-MP Forums Archive
No errors , no warnings - just not working - 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: No errors , no warnings - just not working (/showthread.php?tid=549352)



No errors , no warnings - just not working - Dziugsas - 06.12.2014

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;
}



Re: No errors , no warnings - just not working - Dziugsas - 06.12.2014

Help anyone?


Re: No errors , no warnings - just not working - Schneider - 06.12.2014

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;
}



Re: No errors , no warnings - just not working - Dziugsas - 06.12.2014

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


Re: No errors , no warnings - just not working - Schneider - 06.12.2014

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.


Re: No errors , no warnings - just not working - Dziugsas - 06.12.2014

Nope , its not working.


Re: No errors , no warnings - just not working - Schneider - 06.12.2014

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;
}



Re: No errors , no warnings - just not working - Dziugsas - 07.12.2014

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

Camera does interpolate, SCM working ,GameText working


Re: No errors , no warnings - just not working - Schneider - 07.12.2014

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]);



Re: No errors , no warnings - just not working - Dziugsas - 07.12.2014

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