Crashing when using colors with car
#1

Hi guys, i made everything working, i can use the name of the car , and the id of the car to spawn it.
But when i type like /accar <carid> <color1> <color2> (/accar 522 5 9) the game will just crash.

Anybody know why? The rest works fine.
Heres the code:

pawn Код:
dcmd_accar(playerid, params[])
{
  new VehicleToSpawn = strval(params);
  new SpawnedVeh;

  new str[128];
  new tmp[MAX_STRING];

  if(_LOGIN_Rank[playerid] > 1) {
    if(IsNumeric(params)) {

    }
    else {
      if(sscanf(params, "s", tmp)) {
        SendClientMessage(playerid, COLOR_RED, "No Vehicle Name Given");
      }
      else {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        new Float:Angle;
        GetPlayerFacingAngle(playerid, Angle);
        return SpawnedVeh = CreateVehicle(GetVehicleModelIDFromName(tmp), x + 3 * floatsin(-Angle, degrees), y + 3 * floatcos(-Angle, degrees), z, Angle, 0, 0, 9999999999999999999999999);
      }
    }

                         // 400 t/m 611
    if(VehicleToSpawn > 399 && VehicleToSpawn < 612) {
      new Float:x, Float:y, Float:z;
      GetPlayerPos(playerid, x, y, z);
      new Float:Angle;
      GetPlayerFacingAngle(playerid, Angle);

// printf("%s %d", IsNumeric(params), IsNumeric(params));

      new color1, color2;

      if(sscanf(params, "ddd", VehicleToSpawn, color1, color2)) {
        SpawnedVeh = CreateVehicle(VehicleToSpawn, x + 3 * floatsin(-Angle, degrees), y + 3 * floatcos(-Angle, degrees), z, Angle, 0, 0, 9999999999999999999999999);
      }
      else {
        SpawnedVeh = CreateVehicle(VehicleToSpawn, x + 3 * floatsin(-Angle, degrees), y + 3 * floatcos(-Angle, degrees), z, Angle, color1, color2, 9999999999999999999999999);
      }

// printf("Vehicle ID: %d - Color1: %d - Color 2: %d", VehicleToSpawn, color1, color1, color1, color2, color2, color2);

// new SpawnedVeh = CreateVehicle(VehicleToSpawn, x + 3 * floatsin(-Angle, degrees), y + 3 * floatcos(-Angle, degrees), z, Angle, 0, 0, 9999999999999999999999999);

      if(VehicleToSpawn == 415) {
                         // Upswept Exhaust
        AddVehicleComponent(SpawnedVeh, 1018);
                         // 10x Nitrous
        AddVehicleComponent(SpawnedVeh, 1010);
                         // Win Spoiler
        AddVehicleComponent(SpawnedVeh, 1001);
                         // Right Sideskirt
        AddVehicleComponent(SpawnedVeh, 1007);
                         // Left Sideskirt
        AddVehicleComponent(SpawnedVeh, 1017);
                         // Hydraulics
        AddVehicleComponent(SpawnedVeh, 1087);
      }
      if(VehicleToSpawn == 411) AddVehicleComponent(SpawnedVeh, 1010);
      if(VehicleToSpawn == 568) AddVehicleComponent(SpawnedVeh, 1010);
      if(VehicleToSpawn == 564) PutPlayerInVehicle(playerid, SpawnedVeh, 0);
      if(VehicleToSpawn == 471) AddVehicleComponent(SpawnedVeh, 1010);
    }
    else {
      SendClientMessage(playerid, COLOR_RED, "You Can Only Spawn A Vehicle Between ID 400 And ID 611!");
    }
  }
  return 1;
}
Reply
#2

BUMP
Reply
#3

lol you must use strval
Reply
#4

if you lol, then you can also tell me where to use it.
Reply
#5

what are you trying to do with color1 and color2?
Reply
#6

give the car that color.
Reply
#7

this is a messed up cmd, first creating car, than again..?
Reply
#8

no.. look after the first sscanf, it uses return so it wont create it a second time.

can you find out why it crashes? :O
Reply
#9

Ive found out it crashes at this line

pawn Код:
if(sscanf(params, "ddd", VehicleToSpawn, color1, color2))
Does anybody know why?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)