Vehicle wont create
#1

Hello, I am trying to create a vehicle in my server and when I do the command it let me make one vehicle, It let me change the model,type,color, ect.. Now I go to make another one and do the stuff it says unknow command

Here is the command

To Create:
Код:
if(strcmp(cmd, "/vcreate", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if (PlayerInfo[playerid][pAdmin] >= 5)
			{
                new Float:x,Float:y,Float:z;
				new Float:a;
				new car;
				//new thecar = GetVehicleModel(vehicleid);
				GetPlayerPos(playerid, x, y, z);
				GetPlayerFacingAngle(playerid, a);
				DynamicCars[car][CarModel] = 500;
				DynamicCars[car][CarX] = x;
				DynamicCars[car][CarY] = y;
				DynamicCars[car][CarZ] = z;
				DynamicCars[car][CarAngle] = a;
				DynamicCars[car][FactionCar] = 9;
				DynamicCars[car][CarType] = 0;
				DynamicCars[car][CarColor1] = 1;
				DynamicCars[car][CarColor2] = 1;
				CreateVehicle(DynamicCars[car][CarModel],DynamicCars[car][CarX],DynamicCars[car][CarY],DynamicCars[car][CarZ],DynamicCars[car][CarAngle],DynamicCars[car][CarColor1],DynamicCars[car][CarColor2], -1);
				SaveDynamicCars();
			}
			else
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You're not an administrator.");
			}
		}
		return 1;
	}
To Change the model and color
Код:
	if(strcmp(cmd, "/vmodel", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "USAGE: /vmodel [modelid]");
				return 1;
			}
			new thecar = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 5)
			{
				if(IsPlayerInAnyVehicle(playerid))
				{
 					if(thecar > 400 && thecar < 611)
 					{
					new car = GetPlayerVehicleID(playerid) - 1;
					new vehicleid = GetPlayerVehicleID(playerid);
					DynamicCars[car][CarModel] = thecar;
		 			new wstring[128];
				    format(wstring, sizeof(wstring), "You've set Vehicle ID %d's model to: %d.", vehicleid,thecar);
				    SendClientMessage(playerid,COLOR_ADMINCMD, wstring);
   					new Float:cx,Float:cy,Float:cz;
   					GetVehiclePos(vehicleid,cx,cy,cz);
   					new Float:angle;
   					GetVehicleZAngle(vehicleid, angle);
					DestroyVehicle(vehicleid);
					CreateVehicle(DynamicCars[car][CarModel],DynamicCars[car][CarX],DynamicCars[car][CarY],DynamicCars[car][CarZ],DynamicCars[car][CarAngle],DynamicCars[car][CarColor1],DynamicCars[car][CarColor2], -1);
					PutPlayerInVehicle(playerid,vehicleid,0);
					SetVehiclePos(vehicleid, cx, cy, cz);
     				SetVehicleZAngle(vehicleid, angle);
				    SaveDynamicCars();
				    }
		   			else
					{
					SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "Incorrect Model ID, Correct Model ID's: 400-611.");
					}
				}
 				else
				{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You're not in a vehicle!");
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You're not an administrator.");
			}
		}
		return 1;
	}
	if(strcmp(cmd, "/vcolor", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "USAGE: /vcolor [colorid] [colorid]");
				return 1;
			}
			if (PlayerInfo[playerid][pAdmin] >= 5)
			{
				if(IsPlayerInAnyVehicle(playerid))
				{
					new color1;
					color1 = strval(tmp);
					if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR] 0-126 = Valid Colors."); return 1; }
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "USAGE: /vcolor [colorid] [colorid]");
						return 1;
					}
					new color2;
					color2 = strval(tmp);
					if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR] 0-126 = Valid Colors."); return 1; }

					new car = GetPlayerVehicleID(playerid) - 1;
					new vehicleid = GetPlayerVehicleID(playerid);
					DynamicCars[car][CarColor1] = color1;
					DynamicCars[car][CarColor2] = color2;
					new wstring[128];
		   			format(wstring, sizeof(wstring), "You've set Vehicle ID %d's colors to: %d-%d.", vehicleid,color1,color2);
				    SendClientMessage(playerid,COLOR_ADMINCMD, wstring);
   					new Float:cx,Float:cy,Float:cz;
   					GetVehiclePos(vehicleid,cx,cy,cz);
   					new Float:angle;
   					GetVehicleZAngle(vehicleid, angle);
        			DestroyVehicle(vehicleid);
					CreateVehicle(DynamicCars[car][CarModel],DynamicCars[car][CarX],DynamicCars[car][CarY],DynamicCars[car][CarZ],DynamicCars[car][CarAngle],DynamicCars[car][CarColor1],DynamicCars[car][CarColor2], -1);
					PutPlayerInVehicle(playerid,vehicleid,0);
					SetVehiclePos(vehicleid, cx, cy, cz);
     				SetVehicleZAngle(vehicleid, angle);
				    SaveDynamicCars();
				}
 				else
				{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You're not in a vehicle!");
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You're not an administrator.");
			}
		}
		return 1;
	}
Reply
#2

You're only saving the datas for one vehicle, because of this:
Код:
new car; //It's always 0
Reply
#3

Hi,

I think you try to access an array -1, example: pInfo[-1][pName].
Put printf to see what is the value of the id in the array

Sorry for my bad english, i'm french but i want to help English speakers
Reply
#4

Quote:
Originally Posted by Aly
Посмотреть сообщение
You're only saving the datas for one vehicle, because of this:
Код:
new car; //It's always 0
So delete it?
Reply
#5

If you want to make a dynamic vehicle system you'll have to grow that variable.You can use
Код:
IsValidVehicle(vehicleid)
function to check the next open id.
You can run a loop to see which vehicle is not created, something like:
Код:
new car;
for(new i=0;i<MAX_VEHICLES;i++)
{
    if(!IsValidVehicle(i))
    {
         car = i;
         break;
    }
}
And about the other 2 cmds:

Код:
if(strcmp(cmd, "/vmodel", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "USAGE: /vmodel [modelid]");
				return 1;
			}
			new thecar = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 5)
			{
				if(IsPlayerInAnyVehicle(playerid))
				{
 					if(thecar > 400 && thecar < 611)
 					{
						new vehicleid = GetPlayerVehicleID(playerid);
						DynamicCars[vehicleid][CarModel] = thecar;
						new wstring[128];
						format(wstring, sizeof(wstring), "You've set Vehicle ID %d's model to: %d.", vehicleid,thecar);
						SendClientMessage(playerid,COLOR_ADMINCMD, wstring);
						new Float:cx,Float:cy,Float:cz;
						GetVehiclePos(vehicleid,cx,cy,cz);
						new Float:angle;
						GetVehicleZAngle(vehicleid, angle);
						DestroyVehicle(vehicleid);
						CreateVehicle(DynamicCars[vehicleid][CarModel],cx,cy,cz,angle,DynamicCars[vehicleid][CarColor1],DynamicCars[vehicleid][CarColor2], -1);
						PutPlayerInVehicle(playerid,vehicleid,0);
						SaveDynamicCars();
				    }
		   			else
					{
					SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "Incorrect Model ID, Correct Model ID's: 400-611.");
					}
				}
 				else
				{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You're not in a vehicle!");
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You're not an administrator.");
			}
		}
		return 1;
	}
	if(strcmp(cmd, "/vcolor", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "USAGE: /vcolor [colorid] [colorid]");
				return 1;
			}
			if (PlayerInfo[playerid][pAdmin] >= 5)
			{
				if(IsPlayerInAnyVehicle(playerid))
				{
					new color1;
					color1 = strval(tmp);
					if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR] 0-126 = Valid Colors."); return 1; }
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "USAGE: /vcolor [colorid] [colorid]");
						return 1;
					}
					new color2;
					color2 = strval(tmp);
					if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR] 0-126 = Valid Colors."); return 1; }

					new vehicleid = GetPlayerVehicleID(playerid);
					DynamicCars[vehicleid][CarColor1] = color1;
					DynamicCars[vehicleid][CarColor2] = color2;
					new wstring[128];
		   			format(wstring, sizeof(wstring), "You've set Vehicle ID %d's colors to: %d-%d.", vehicleid,color1,color2);
				    SendClientMessage(playerid,COLOR_ADMINCMD, wstring);
   					new Float:cx,Float:cy,Float:cz;
   					GetVehiclePos(vehicleid,cx,cy,cz);
   					new Float:angle;
   					GetVehicleZAngle(vehicleid, angle);
        			DestroyVehicle(vehicleid);
					CreateVehicle(DynamicCars[vehicleid][CarModel],cx,cy,cz,angle,DynamicCars[vehicleid][CarColor1],DynamicCars[vehicleid][CarColor2], -1);
					PutPlayerInVehicle(playerid,vehicleid,0);
				    SaveDynamicCars();
				}
 				else
				{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You're not in a vehicle!");
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You're not an administrator.");
			}
		}
		return 1;
	}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)