Getcarid problem
#1

Alright another problem.. I have a getcarid command, but whenever I type it the last parts will be erased.
For example if I type /getcarid 5 it will remove the . from, ("You have teleported vehicle ID 5 to you.") if you do /getcarid 55 it will remove the u and the . from that message, so for every digit in the vehicle ID it removed that from the end of the text.

One more problem in it is that you can teleport a car to you that doesnt exit.. For example /getcarid 1337 when vehicle id 1337 doesn't exist (It still says you teleported it to you instead of saying nothing, or something like "Vehicle 1337 does not exist")
Here is my command
Код:
command(getcarid, playerid, params[])
{
	new id, string[40];
	if(sscanf(params, "d", id))
	{
	    if(Player[playerid][AdminLevel] >= 4)
	    {
	    	SendClientMessage(playerid, WHITE, "SYNTAX: /getcarid [carid]");
	    }
	}
	else
	{
	    if(Player[playerid][AdminLevel] >= 4)
	    {
	        new Float: PosX, Float: PosY, Float: PosZ;
	        GetPlayerPos(playerid, PosX, PosY, PosZ);
			SetVehiclePos(id, PosX, PosY, PosZ);
	        format(string, sizeof(string), "You have teleported vehicle ID %d to you.", id);
	        SendClientMessage(playerid, WHITE, string);
	    }
	}
	return 1;
}
Reply
#2

Change string[40] to string[50]. The reason why it used to delete the last digits is because the string length was too short. The [40] is the length of the sentence you want the player to receive. So, if you count the characters, you'll see it`s more than 40. Anyway, 50 I think it`s enough.
Reply
#3

Thanks, but how would I make it so that it displays a message if the vehicle doesnt exist?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)