SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 25/08/2010, 09:42 AM   #1
Frankieh'
Little Clucker
 
Join Date: Oct 2007
Posts: 16
Reputation: 0
Default Not working properly - /cardescription

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!

Code:
new car, Madec[MAX_VEHICLES];
Code:
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;
	}
Frankieh' is offline  
Old 25/08/2010, 10:15 AM   #2
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 3,554
Reputation: 130
Default Re: Not working properly - /cardescription

Why are people still using strtok, and wtf is with 256 cell size? You don't need more than 128.
The second
pawn Code:
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.
LarzI is offline  
Old 25/08/2010, 10:21 AM   #3
Frankieh'
Little Clucker
 
Join Date: Oct 2007
Posts: 16
Reputation: 0
Default Re: Not working properly - /cardescription

Quote:
Originally Posted by LarzI View Post
Why are people still using strtok, and wtf is with 256 cell size? You don't need more than 128.
The second
pawn Code:
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.
Frankieh' is offline  
Old 25/08/2010, 10:25 AM   #4
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 3,554
Reputation: 130
Default Re: Not working properly - /cardescription

imo try learning dcmd (or zcmd).
It's so simple, and much faster + more convinient
LarzI is offline  
Old 25/08/2010, 02:44 PM   #5
Frankieh'
Little Clucker
 
Join Date: Oct 2007
Posts: 16
Reputation: 0
Default Re: Not working properly - /cardescription

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?
Frankieh' is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search not working properly WARBI General 14 19/07/2010 02:04 PM
Random isn't working properly :S Maxips2 Help Archive 10 12/07/2010 11:31 AM
[HELP]Realchat not working properly Lilcuete Help Archive 11 19/06/2010 02:37 PM
/Admins not working properly `Robo Help Archive 0 27/01/2010 07:11 PM


All times are GMT. The time now is 09:19 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.