Not working properly - /cardescription
#1

Hi,
I have created command which adds description (as 3DTextLabel) to car. It's working nice, but if I want to edit the text (Update3DTextLabel) there is no reaction.
Here is my code, look at it and if you know what's the problem write in this topic please . Thanks!

Код:
new car, Madec[MAX_VEHICLES];
Код:
if(strcmp(cmd, "/cardescription", true) == 0)
	{
		new string[256], tmp[256], Text3D:vehicle3Dtext[MAX_VEHICLES];
	    if(IsPlayerConnected(playerid))
	    {
	    	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "Ceresto: /cardescription [CarID] [Text]");
				return 1;
			}
			car = strval(tmp);
			if (IsPlayerAdmin(playerid))
			{
				new length = strlen(cmdtext);
				while ((idx < length) && (cmdtext[idx] <= ' '))
				{
					idx++;
				}
				new offset = idx;
				new result[256];
				while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
				{
					result[idx - offset] = cmdtext[idx];
					idx++;
				}
				result[idx - offset] = EOS;
				if(!strlen(result))
				{
					SendClientMessage(playerid, COLOR_WHITE, "Ceresto: /cardescription [CarID] [Text]");
					return 1;
				}
				if(Madec[car] == 0)
				{
					format(string, sizeof(string), "Ceresto: Car (ID: %d) description set!.", car);
					SendClientMessage(playerid, COLOR_WHITE, string);
					format(string, sizeof(string), "Ceresto: Result: (%s).", result);
					SendClientMessage(playerid, COLOR_YELLOW, string);
				    vehicle3Dtext[car] = Create3DTextLabel(result, COLOR_LIGHTBLUE, 0.0, 0.0, 0.0, 50.0, 0, 1 );
				    Attach3DTextLabelToVehicle(vehicle3Dtext[car], car, 0.0, 0.0, 0.0);
				    Madec[car] = 1;
				    return 1;
				}
				else if(Madec[car] == 1)
				{
					format(string, sizeof(string), "Ceresto: Car (ID: %d) description changed.", car);
					SendClientMessage(playerid, COLOR_WHITE, string);
					format(string, sizeof(string), ""Ceresto: Result: (%s).", result);
					SendClientMessage(playerid, COLOR_YELLOW, string);
				    Update3DTextLabelText(vehicle3Dtext[car], COLOR_LIGHTBLUE, result);
				    Madec[car] = 1;
				    return 1;
				}
				return 1;
			}
		}
		return 1;
	}
Reply
#2

Why are people still using strtok, and wtf is with 256 cell size? You don't need more than 128.
The second
pawn Код:
Madec[car] = 1;
is unecaserry.. Why set it's value to 1, if it's already 1?

What the problem is, I can't say. I did my best to look for any "errors", but couldn't find anything, sorry.
Reply
#3

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Why are people still using strtok, and wtf is with 256 cell size? You don't need more than 128.
The second
pawn Код:
Madec[car] = 1;
is unecaserry.. Why set it's value to 1, if it's already 1?

What the problem is, I can't say. I did my best to look for any "errors", but couldn't find anything, sorry.
It was 0, not 1.
So what I should use instead of strtok? :P.
Reply
#4

imo try learning dcmd (or zcmd).
It's so simple, and much faster + more convinient
Reply
#5

I was using dcmd in different script. This is test one and it's enough fast. Anybody knows why te text isn't chaning while using Update3DText?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)