create3dtextlabel in a loop help
#1

Now I thought I fixed the issue but it still happens can someone suggest a way to fix it.

pawn Код:
public PickupMessages()
{
    new string[128], Float: playX, Float: playY, Float: playZ;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerInRangeOfPoint(i, 9, playX, playY, playZ))
        {
            if(IsPlayerConnectedEx(i) && IsPlayerSpawned(i))
            {

                for(new h = 0; h < sizeof(Businesses); h++)
                {
                    if(strcmp(Businesses[h][bOwner], "Nobody", true) == 0)
                    {
                        if(Businesses[h][bPrice] == -1)
                        {
                            format(string, sizeof(string), "Business %d (%s) Unavailable.", h, Businesses[h][bName]);
                            CreateDynamic3DTextLabel(string, YELLOW, Businesses[h][bExteriorX], Businesses[h][bExteriorY], Businesses[h][bExteriorZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 5.0);
                        }
                        else
                        {
                            format(string, sizeof(string), "Business %d (%s)\nAvailable to buy for %d (/buybusiness).", h, Businesses[h][bName], Businesses[h][bPrice]);
                            CreateDynamic3DTextLabel(string, YELLOW, Businesses[h][bExteriorX], Businesses[h][bExteriorY], Businesses[h][bExteriorZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 5.0);
                        }
                    }
                    else
                    {
                        format(string, sizeof(string), "Business %d (%s) Owner: %s\nPress ~k~~PED_DUCK~  to enter", h, Businesses[h][bName], Businesses[h][bOwner]);
                        CreateDynamic3DTextLabel(string, YELLOW, Businesses[h][bExteriorX], Businesses[h][bExteriorY], Businesses[h][bExteriorZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 5.0);
                    }
                }
                for(new h = 0; h < sizeof(Houses); h++)
                {
                    if(GetPlayerVirtualWorld(i) == 0)
                    {
                        if(strcmp(Houses[h][hOwner], "Nobody", true) == 0)
                        {
                            if(Houses[h][HousePrice] == -1)
                            {
                                format(string, sizeof(string), "House %d Unavailable.", h, Houses[h][HousePrice]);
                                CreateDynamic3DTextLabel(string, YELLOW, Houses[h][hExteriorX], Houses[h][hExteriorY], Houses[h][hExteriorZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 5.0);
                            }
                            else
                            {
                                format(string, sizeof(string), "House %d\nAvailable to buy for %d (/buyhouse).", h, Houses[h][HousePrice]);
                                CreateDynamic3DTextLabel(string, YELLOW, Houses[h][hExteriorX], Houses[h][hExteriorY], Houses[h][hExteriorZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 5.0);
                            }
                        }
                        else
                        {
                            format(string, sizeof(string), "House %d Owner: %s\nPress ~k~~PED_DUCK~ to enter", h, Houses[h][hOwner]);
                            CreateDynamic3DTextLabel(string, YELLOW, Houses[h][hExteriorX], Houses[h][hExteriorY], Houses[h][hExteriorZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 5.0);
                        }
                    }
                }
                for(new h = 0; h < sizeof(Jobs); h++)
                {
                    if(IsPlayerInRangeOfPoint(i, 5, Jobs[h][JobJoinPosX], Jobs[h][JobJoinPosY], Jobs[h][JobJoinPosZ]))
                    {
                        if(GetPlayerVirtualWorld(i) == Jobs[h][JobJoinPosWorld] && GetPlayerInterior(i) == Jobs[h][JobJoinPosInterior])
                        {
                            format(string, sizeof(string), "~w~Job ~y~%s ~w~ ~n~ /joinjob", Jobs[h][JobName]);
                            GameTextForPlayer(i, string, 3500, 3);
                        }
                    }
                    if(IsPlayerInRangeOfPoint(i, 5, Jobs[h][JobMiscLocationOneX], Jobs[h][JobMiscLocationOneY], Jobs[h][JobMiscLocationOneZ]))
                    {
                        if(GetPlayerVirtualWorld(i) == Jobs[h][JobMiscLocationOneWorld] && GetPlayerInterior(i) == Jobs[h][JobMiscLocationOneInterior])
                        {
                            format(string, sizeof(string), "~w~ %s", Jobs[h][JobMiscLocationOneMessage]);
                            GameTextForPlayer(i, string, 3500, 3);
                        }
                    }
                    if(IsPlayerInRangeOfPoint(i, 5, Jobs[h][JobMiscLocationTwoX], Jobs[h][JobMiscLocationTwoY], Jobs[h][JobMiscLocationTwoZ]))
                    {
                        if(GetPlayerVirtualWorld(i) == Jobs[h][JobMiscLocationTwoWorld] && GetPlayerInterior(i) == Jobs[h][JobMiscLocationTwoInterior])
                        {
                            format(string, sizeof(string), "~w~ %s", Jobs[h][JobMiscLocationTwoMessage]);
                            GameTextForPlayer(i, string, 3500, 3);
                        }
                    }
                }

                for(new h = 0; h < sizeof(Groups); h++)
                {
                    format(string, sizeof(string), "~w~Group %s's HQ\nPress ~k~~PED_DUCK~ to enter", Groups[h][GroupName]);
                    CreateDynamic3DTextLabel(string, YELLOW, Groups[h][HQExteriorX], Groups[h][HQExteriorY], Groups[h][HQExteriorZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 5.0);
                    if(IsPlayerInRangeOfPoint(i, 5, Groups[h][SafeX], Groups[h][SafeY], Groups[h][SafeZ]))
                    {
                       if(GetPlayerVirtualWorld(i) == Groups[h][SafeWorld])
                        {
                            format(string, sizeof(string), "~w~Group ~y~%s's ~w~ Safe.", Groups[h][GroupName]);
                            GameTextForPlayer(i, string, 3500, 3);
                        }
                    }
                }
            }
        }
        break;
    }
    return 1;
}
Reply
#2

ummm, so what problem do u have with this code?
Reply
#3

Quote:
Originally Posted by Yiin
Посмотреть сообщение
ummm, so what problem do u have with this code?
If you go in the area of it it creates the label hundreds of times causing lag.
Reply
#4

Bump
Reply
#5

timer setting?
Reply
#6

Quote:
Originally Posted by Anak
Посмотреть сообщение
timer setting?
There is no timer.
Reply
#7

Bump
Reply
#8

Why is the CreateDynamic3DTextLabel in a player loop? If your MAX_PLAYERS is 500, you're creating each label 500 times. Don't put the parts with CreateDynamic3DTextLabel inside a player loop.
Reply
#9

Quote:
Originally Posted by Basssiiie
Посмотреть сообщение
Why is the CreateDynamic3DTextLabel in a player loop? If your MAX_PLAYERS is 500, you're creating each label 500 times. Don't put the parts with CreateDynamic3DTextLabel inside a player loop.
Still does the same thing.
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)