Worries optimision...
#1

Hello to you.

So I have an input into a house pickup system.
When the player moves the pickup that teleports in the house.
The trouble, instead it is instantaneous, it takes a few seconds (3-4) before the teleport and I do not understand why.

Could you help me?

pawn Код:
public OnPlayerPickUpDynamicPickup(playerid,pickupid)
{
    new Float:cx, Float:cy, Float:cz;
    GetPlayerPos(playerid, cx, cy, cz);
    for(new houseid = 0; houseid < totalhouses; houseid++)
    {
        if(pickupid == HousePickup[houseid])
        {
            if(PlayerToPointStripped(1, playerid,HouseInfo[houseid][hEntrancex], HouseInfo[houseid][hEntrancey], HouseInfo[houseid][hEntrancez], cx, cy, cz))
            {
                if(house_isProprio(playerid, houseid) || house_isLocataire(playerid, houseid) || HouseInfo[houseid][hLock] == 0 || HouseInfo[houseid][hOwned] == 0 || (HouseInfo[houseid][hLock] == 1 && HouseInfo[houseid][hOwned] == 0))
                {
                    if(HouseInfo[houseid][hOwned] == 0) // No buy
                    {
                   
                    }
                    if(HouseInfo[houseid][hEdited] == 0)
                    {
                        SetVirtualWorld(playerid, houseid);
                    }
                    else if(HouseInfo[houseid][hEdited] == 1)
                    {
                        SetVirtualWorld(playerid, 0);
                    }
                    if(house_isProprio(playerid, houseid) || house_isLocataire(playerid, houseid))
                    {
                        HouseInfo[houseid][hFrigo] += biz_recupration[playerid];
                        biz_recupration[playerid] = 0;
                    }
                    SetInterior(playerid,HouseInfo[houseid][hInt]);
                    SetPlayerPos(playerid, HouseInfo[houseid][hExitx], HouseInfo[houseid][hExity], HouseInfo[houseid][hExitz]);
                    PlayerInfo[playerid][pInHouse] = houseid;
                    if(HouseInfo[houseid][hOwned] == 0)
                    SendClientMessage(playerid, COLOR_MAISON, "You see a house. You can buy.");
                }
                else
                {
                    GameTextForPlayer(playerid, "~r~Door closed..", 5000, 1);
                }
                return 1;
            }
        }
    }
    return 1;
}
Reply
#2

Using break should work, because it continues until it reaches the totalhouse, so break should work, so what this means if it finds the current house you're near, it breaks the loop, it would not continue

pawn Код:
public OnPlayerPickUpDynamicPickup(playerid,pickupid)
{
    new Float:cx, Float:cy, Float:cz;
    GetPlayerPos(playerid, cx, cy, cz);
    for(new houseid = 0; houseid < totalhouses; houseid++)
    {
        if(pickupid == HousePickup[houseid])
        {
            if(PlayerToPointStripped(1, playerid,HouseInfo[houseid][hEntrancex], HouseInfo[houseid][hEntrancey], HouseInfo[houseid][hEntrancez], cx, cy, cz))
            {
                if(house_isProprio(playerid, houseid) || house_isLocataire(playerid, houseid) || HouseInfo[houseid][hLock] == 0 || HouseInfo[houseid][hOwned] == 0 || (HouseInfo[houseid][hLock] == 1 && HouseInfo[houseid][hOwned] == 0))
                {
                    if(HouseInfo[houseid][hOwned] == 0) // No buy
                    {
                        //None
                    }
                    else if(HouseInfo[houseid][hEdited] == 0)
                    {
                        SetVirtualWorld(playerid, houseid);
                    }
                    else if(HouseInfo[houseid][hEdited] == 1)
                    {
                        SetVirtualWorld(playerid, 0);
                    }
                    else if(house_isProprio(playerid, houseid) || house_isLocataire(playerid, houseid))
                    {
                        HouseInfo[houseid][hFrigo] += biz_recupration[playerid], biz_recupration[playerid] = 0;
                    }

                    SetInterior(playerid,HouseInfo[houseid][hInt]), SetPlayerPos(playerid, HouseInfo[houseid][hExitx], HouseInfo[houseid][hExity], HouseInfo[houseid][hExitz]);
                    PlayerInfo[playerid][pInHouse] = houseid;

                    if(HouseInfo[houseid][hOwned] == 0) SendClientMessage(playerid, COLOR_MAISON, "You see a house. You can buy.");
                }
                else GameTextForPlayer(playerid, "~r~Door closed..", 5000, 1);
            }
            break;
        }
    }
    return 1;
}
Reply
#3

It does not work, it always takes a few seconds before entering the house...
Reply
#4

Quote:
Originally Posted by JacobWilkerson
Посмотреть сообщение
It does not work, it always takes a few seconds before entering the house...
Hope this fixes the problem

pawn Код:
public OnPlayerPickUpDynamicPickup(playerid,pickupid)
{
    new Float:cx, Float:cy, Float:cz;
    GetPlayerPos(playerid, cx, cy, cz);
    for(new i = 0; i < totalhouses; i++)
    {
        if( pickupid == HousePickup[ i ] )
        {
            if( PlayerToPointStripped( 1, playerid, HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez], cx, cy, cz ) )
            {
                if( house_isProprio( playerid, i ) || house_isLocataire( playerid, i ) )
                {
                    SetInterior( playerid, HouseInfo[i][hInt] );
                    SetPlayerPos( playerid, HouseInfo[i][hExitx], HouseInfo[i][hExity], HouseInfo[i][hExitz] );

                    PlayerInfo[playerid][pInHouse] = i;

                    switch( HouseInfo[ i ][ hEdited ] )
                    {
                        case 1: SetVirtualWorld(playerid, 0);
                        default: SetVirtualWorld(playerid, i); //Suspicious code that might be the problem.
                    }

                    if( house_isProprio( playerid, i ) || house_isLocataire( playerid, i ) ) {
                        HouseInfo[ i ][ hFrigo ] += biz_recupration[playerid], biz_recupration[playerid] = 0;
                    }
                    if(HouseInfo[ i ][ hLock ] == 1) {
                        GameTextForPlayer(playerid, "~r~Door closed..", 5000, 1);
                    }
                    if(HouseInfo[ i ][ hOwned ] == 0) {
                        SendClientMessage(playerid, COLOR_MAISON, "You see a house. You can buy.");
                    }
                }
            }  
            break;          
        }
    }
    return 1;
}
Reply
#5

It's the same ...
Reply
#6

up...
Reply
#7

I tried something else:
When the player enters the pickup, that it displays a dialog to enter or not in the house.
Except that the dialogue takes a few seconds to appear, here is the code:

pawn Код:
public OnPlayerPickUpDynamicPickup(playerid,pickupid)
{
    for(new i = 0; i < totalhouses; i++)
    {
        if(pickupid == HousePickup[i])
        {
            if(IsPlayerInRangeOfPoint(playerid, 1.0, HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
            {
                ShowPlayerDialog(playerid, 852, DIALOG_STYLE_MSGBOX, "Maison/appartement/buisness:", "Voulez-vous entrer а l'intйrieur?", "Entrer", "Quitter");
                return 1;
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)