Weird string array bug (Experienced scripters please) -
LocMax - 29.06.2014
So, I have a vehicle enum with variable - vOwner in it.
It'd look like:
Код:
enum VInfo
{
vOwner,
...
}
And then OnGameModeInit, I load the info from database about that vehicle:
pawn Код:
db_get_field_assoc(re, "owner", Field, 21); format(VehicleInfo[vid][vOwner], 21, "%s", Field);
However, that works but the strcmp isn't working which is under it:
pawn Код:
if(strcmp(VehicleInfo[vid][vOwner], "Sale") == 0
{
}
Now, if I add [21] to the vOwner variable (it would be like "vOwner[21]"), it'll mess up the textdraws for some reason...
Any ideas?
Respuesta: Weird string array bug (Experienced scripters please) -
Leon9741 - 29.06.2014
Try:
pawn Код:
if(strcmp(VehicleInfo[vid][vOwner], "Sale", true, 21) == 0)
{
// Something
}
Re: Weird string array bug (Experienced scripters please) -
LocMax - 29.06.2014
Now the server won't open..
Код:
[18:50:20] =======================================
[18:50:20] | |
[18:50:20] | YSI version 3.09.0684 |
[18:50:20] | By Alex "******" Cole |
[18:50:20] | |
[18:50:20] =======================================
[18:50:20]
[18:50:20] >>>>>>>>>>>> vehicle 1 reached 1
and it closes.
Respuesta: Weird string array bug (Experienced scripters please) -
Leon9741 - 29.06.2014
Are you sure that
VehicleInfo[vid][vOwner] have any value?
pawn Код:
printf("Test: %s", VehicleInfo[vid][vOwner]);
To get values from db i use:
string:
pawn Код:
cache_get_field_content(i, "owner", variable);
int / float / other
pawn Код:
new content;
cache_get_field_content(i, "owner", content); variable = strval(content) | variable = floatstr(content)
Re: Weird string array bug (Experienced scripters please) -
Konstantinos - 29.06.2014
You cannot compare an integer with a string with strcmp, it'll give warning about argument type mismatch 1.
Change to:
pawn Код:
// in the enum:
vOwner[21],
...
pawn Код:
db_get_field_assoc(re, "owner", VehicleInfo[vid][vOwner], 21);
and check as Leon9741 showed you.
Re: Weird string array bug (Experienced scripters please) -
LocMax - 29.06.2014
When I add it like:
vOwner[21]
Then the textdraws get messy, here screenshot:
Without [21]:
With [21]:
Respuesta: Weird string array bug (Experienced scripters please) -
Leon9741 - 29.06.2014
Maybe the textdraws have another problem, with "
[21]" the vehicles load fine?
Re: Weird string array bug (Experienced scripters please) -
Konstantinos - 29.06.2014
Textdraws have nothing to do with the owner's name of some vehicles and in the pictures, I do see different textdraws.
Re: Weird string array bug (Experienced scripters please) -
LocMax - 29.06.2014
Yeah, I really can't see the problem, why would textdraws get messed up by a vehicle system?
The vehicles work fine when I remove the [21], but when I add it then they mix up.
I also have house and business system, same process just different variables, and it doesn't mess up the textdraws.
Also, when I add the [21], if you press ESC on team selection, you'll spawn and it'll flood the chat with "Team set.", "Skin set."
These are my textdraws:
pawn Код:
new Text:OutLook[5] = Text:INVALID_TEXT_DRAW;
new Text:Teams[5] = Text:INVALID_TEXT_DRAW;
new Text:Classes[5] = Text:INVALID_TEXT_DRAW;
new Text:BoxMsg[5] = Text:INVALID_TEXT_DRAW;
new Text:StatsTD[MAX_PLAYERS] = Text:INVALID_TEXT_DRAW;
Re: Weird string array bug (Experienced scripters please) -
LocMax - 29.06.2014
EDIT: Fixed the problem by moving the label creation from gamemodeinit to vehiclespawn.
Thanks all for help, sorry for doublepost