strval Problemm.
#1

pawn Code:
if (strcmp(cmd, "/addvehicle", true) == 0) {
    new addmodelid, color1, color2, addtmp[256], addquery[512];
      new Float:Angle;

    if (PlayerInfo[playerid][AdminLevel] < 5) {
      SendClientMessage(playerid, COLOR_RED, "You must be server administrator if you want to add faction car.");
      return 1;
    }
    addtmp = strtok(cmdtext, idx);

    if (!strlen(addtmp)) {
      SendClientMessage(playerid, COLOR_GREY, "USAGE: /addvehicle [model_id] [color1] [color2]");
      return 1;
    }
    addmodelid = strval(addtmp);

    addtmp = strtok(cmdtext, idx);

    if (!strlen(addtmp)) {
      SendClientMessage(playerid, COLOR_GREY, "USAGE: /addvehicle [model_id] [color1] [color2]");
      return 1;
    }
    color1 = strval(addtmp);

    addtmp = strtok(cmdtext, idx);

    if (!strlen(addtmp)) {
      SendClientMessage(playerid, COLOR_GREY, "USAGE: /addvehicle [model_id] [color1] [color2]");
      return 1;
    }
    color2 = strval(addtmp);
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, Angle);
        new test[256];
        format(test, 256, "%d", addmodelid);
        SendClientMessage(playerid, COLOR_WHITE, test);
    format(addquery, sizeof (addquery), "INSERT INTO static_vehicles (model_id, x, y, z, angle, color1, color2) VALUES (%d, %f, %f, %f, %f, %d, %d)", addmodelid, x, y, z, Angle, color1, color2);
    mysql_query(addquery);
    SetPlayerPos(playerid, x + 5, y, z);
    CreateVehicle(addmodelid, x, y, z, Angle, color1, color2, 6000);
    return 1;
  }
so what is the problem, when i add vehicle, its all ok until it convert modelid, color1 and color2 to integer with strval.

When it do that, the string doesn't convert correct, it convert string 599 to 15230, and that number just increase.


FIXED
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)