Car cmd not working -
[FBI]M.Vulture[XAC] - 01.01.2013
Hey all, i have a problem:
When I run my server everything is ok, but after some time my car cmd stop working, and idk why (its after some time or after i type a cmd, i dont know)
I looked at my script and everyting looks ok:
Код:
CMD:car(playerid,params[])
{
#pragma unused params
if(pS[Zone] != Normal && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Red,"You are not allowed to use this command in this zone");
if(pS[DoingStunt] != Negative && pS[DoingStunt] != 255) return SendClientMessage(playerid,Red,"You are not allowed to use this command when you are doing a stunt! exit your vehicle.");
if(IsPlayerInArea(playerid,383.865234,425.736877, 2433.927001,2475.773925) == 1) return SendClientMessage(playerid,Red,"You cannot spawn a vehicle in this building!");
if(IsPlayerInArea(playerid,1915.172,2008.595,1599.869,1646.58) == 1) return SendClientMessage(playerid,Red,"You cannot spawn a vehicle in this Green spawnzone!");
if(!strlen(params)) return ShowVehicleDialog(playerid);
new Index;
new tmp[256]; tmp = strtok(params,Index);
new tmp2[256]; tmp2 = strtok(params,Index);
new tmp3[256]; tmp3 = strtok(params,Index);
if(!strlen(tmp)) return
SendClientMessage(playerid,Red,"/car [ModelID/Name] [Colour1] [Colour2]");
new car;
new colour1, colour2;
if(!IsNumeric(tmp))
car = GetVehicleModelIDFromName(tmp);
else car = strval(tmp);
if(car < 400 || car > 611) return SendClientMessage(playerid,Red,"Invalid Vehicle Model ID!");
switch (car)
{
case 520,476,425,447,469: if(pS[Admin] < 1 && pS[Vip] < 2) return SendClientMessage(playerid,Red,"This vehicle is only spawnable for Admins and Vips!");
case 464,465,501,441,594,564: return SendClientMessage(playerid,Red,"RC vehicles are not allowed!");
case 569,590,570,537,538,449,432,435,450,591,606,607,610,584,608,611: return SendClientMessage(playerid,Red,"This vehicle is not allowed!");
}
if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
return SpawnCar(playerid,car,colour1,colour2);
}
Код:
public SpawnCar(playerid,carid,color1,color2)
{
new KeepSpeed,NewVehicle,Float:Velocity[3];
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, Red, "Get out this vehicle before you can spawn a car!");
GetPlayerFacingAngle(playerid,pA);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
KeepSpeed = 1;
GetVehiclePos(pS[InCarId],pX,pY,pZ);
GetVehicleZAngle(pS[InCarId], pA);
GetVehicleVelocity(pS[InCarId], Velocity[0], Velocity[1], Velocity[2]);
}
else
{
GetPlayerPos(playerid,pX,pY,pZ);
}
if(Player[playerid][Zone] == Normal && IsPlayerInArea(playerid,-175.1681,502.1487,2382.287,2615.844))
{
if(CheckVehicleType(carid) == Heli)
{
pX = 1596.4119;
pY = 1579.4218;
pZ = 17.6372;
pA = 180.2878;
}
if(CheckVehicleType(carid) == Plane)
{
pX = 1477.2361;
pY = 1750.3055;
pZ = 10.5176;
pA = 180.2878;
}
if(CheckVehicleType(carid) == Boat)
{
pX = 11.1016;
pY = 3036.5537;
pZ = 5.2490;
pA = 76.4390;
}
if(CheckVehicleType(carid) == Attack || CheckVehicleType(carid) == Big)
{
pX = 509.8824;
pY = 2378.3276;
pZ = 29.7696;
pA = 237.0443;
}
}
RemovePlayerCar(playerid);
NewVehicle = CreateVehicle(carid,pX,pY,pZ,pA, color1, color2, -1);
PutPlayerInVehicle(playerid,NewVehicle,0);
LinkVehicleToInterior(NewVehicle,GetPlayerInterior(playerid));
SetVehicleVirtualWorld(NewVehicle, GetPlayerVirtualWorld(playerid));
SetVehicleZAngle(NewVehicle, pA);
pS[CarId] = NewVehicle;
pS[InCarModel] = GetVehicleModel(pS[InCarId]);
if(KeepSpeed == 1)
{
SetVehicleVelocity(NewVehicle, Velocity[0], Velocity[1], Velocity[2]);
}
format(pS[String], 256, "You have Spawned a [%s] (Model: %d) with Colours: %d,%d ", VehiclesName[carid-400], carid, color1, color2);
return SendClientMessage(playerid,Green, pS[String]);
}
After some time when i type /car carname color1 color2 or /car the server tell "server: unknown command"
Please help me, i have 3 months trying to solve this
AW: Car cmd not working -
IPrototypeI - 01.01.2013
At first you have to return a value it have to be 1 because die commandprocessor hook OnPlayerCommandtext.
Then if you use a Commandprocessor then try to use sscanf too, because it's faster and easyier