3DText Dosent updates or it is my script which dosent makes sence?
#1

I am scripting all day long to get this working, but somehow, its just wont work! -.-
I dont know what's wrong with it, I've asked many people which helped me before, but it is too much questions, so I guess its arrogant by me =[.

Anyways, the script is supposed to Create3DTextLabel information for a house if its not exsiting already and when someone /buyhouse its supposed to update the TextLabel into a red colour and another string, but this this! dosent works, it creates new 3DTextLabel over the exsiting on‌e =[!

Seriously, I dont know why it is not working, I think it might be arrays problem or if and elses problem. - Just an opinion of mine.
I am actually a beginner so I do not have much experience.
Anyways, what I am trying to say its that I could use some help as for making this work properly, because it dosent works as its supposed to work - good an properly.
Here's an image which showing you guys, what's the actual problem ( creating a new 3D text instead of updating the exsiting one )



Here is my script that is incharge of the 3DTextLabels :
pawn Код:
stock Create3DHouse()
{
    for(new NewHouseID; NewHouseID<sizeof(Houses); NewHouseID++)
    {
        if(!Houses[NewHouseID][hExteriorY]) continue;
        new string[ 96 ], Text3D:FoSale[4500], hExsitsS[4500], hExsitsN[4500];
        if(strcmp(Houses[NewHouseID][hOwner], "Nobody", true) == 0)
        {
        format(string, sizeof(string), "[House] %d\n buy price: %d (/buyhouse)", NewHouseID, Houses[NewHouseID][HousePrice]);
        if(hExsitsN[NewHouseID] == 1)
        {
        Update3DTextLabelText(FoSale[NewHouseID], HOUSE_YSELL, string);
        hExsitsS[NewHouseID] = 1;
        } else {
        FoSale[NewHouseID] = Create3DTextLabel(string, HOUSE_YSELL, Houses[NewHouseID][hExteriorX], Houses[NewHouseID][hExteriorY], Houses[NewHouseID][hExteriorZ], 30.0, 0, 1);
        hExsitsS[NewHouseID] = 1; }
        } else  {
        format(string, sizeof(string), "[House]\n %d", NewHouseID);
        if(hExsitsS[NewHouseID] == 1)
        {
        Update3DTextLabelText(FoSale[NewHouseID], HOUSE_NSELL, string);
        hExsitsN[NewHouseID] = 1;
        }
        else
        {
        FoSale[NewHouseID] = Create3DTextLabel(string, HOUSE_NSELL, Houses[NewHouseID][hExteriorX], Houses[NewHouseID][hExteriorY], Houses[NewHouseID][hExteriorZ], 30.0, 0, 1);
        hExsitsN[NewHouseID] = 1;
        }
    }
}
What I am willing to do, is to get this working properly, and get some assistance from you guys.
Please, every assistance or suggestion or even a post will be most appericated, thank you.
Reply
#2

Can you explain the use of hExsitsS and hExsitsN?
Reply
#3

hExsitsS means 'House for sale, exsiting(Formerly (h)ouse(Exsits)ing(s)ale)', the usage of it is
that if the 3DText of 'HouseForSale' is exsiting so it wont create new one and update the exsisting one to a format which says that the house was sold, but if there is no 3DText of 'HouseForSale', so it'll create new one which says that the house was sold, so there wont be any crashes or something. ( IT has been created to make sure that the Update3DTextLabelText wont be NULL )
And hExsitsN is just the opposite of hExsitsS.
Reply
#4

When do you use the Create3DHouse function?
Reply
#5

On GameModeInit and Vortex 1's /createhouse 'complete' code.
Its replacing the 'GameTextForPlayer' and house icon pickups, as I hate it.
Reply
#6

Try making FoSale, hExsitsS and hExsitsN global.
Reply
#7

Great! thank you.
May I ask you a question? how'd you know that it should be global?
Reply
#8

Because local variables lose their value when function ends and next time reset to 0, so this

pawn Код:
if(hExsitsN[NewHouseID] == 1)
will always fail.
Reply
#9

You mean that a local variable which has value of a global variable has to be continual even after the function ends and therfor we have to make them global?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)