/getcar problem. Only spawns car IDs up to 3 or 4
#1

Hi, here is my /getcar CMD. This spawns car IDs to the users location. The only problem is it only spawns up to car ID 2. We had 3 players online at the time we tested the command.

pawn Код:
CMD:getcar(playerid, params[]) {
        if(playerVariables[playerid][pAdminLevel] >= 3)
        {
            new vehid,messageString[64],logString[64],Float:x, Float:y, Float:z, Float:vehx, Float:vehy, Float:vehz;
            if(sscanf(params, "u", vehid))
            {
                SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/getcar [vehicleid]");
                return 1;
            }
            if(vehid != INVALID_VEHICLE_ID)
            {
                GetPlayerPos(playerid, x, y, z);
                GetVehiclePos(vehid, vehx, vehy, vehz);
                SetVehiclePos(vehid, x, y+4, z+1);
                SetVehicleVirtualWorld(vehid, GetPlayerVirtualWorld(playerid));
                LinkVehicleToInterior(vehid, GetPlayerInterior(playerid));
                format(messageString, sizeof(messageString), "You have teleported car ID {CD0000}%d{FFFFFF} to your location.", vehid);
                SendClientMessage(playerid, COLOR_WHITE, messageString);

                format(logString, sizeof(logString), "%s has teleported car ID %d (coords: %d, %d, %d)", playerVariables[playerid][pNormalName], vehid, vehx, vehy, vehz);
                mysql_real_escape_string(logString, logString);
                adminLog(logString);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "Invalid vehicle ID.");
            }
        }
        return 1;
}
Reply
#2

Replace 'u' with 'd' in your sscanf line. You're making sscanf rely on player IDs and names, as opposed to integers/digits which is what a vehicle id is in sscanf - it doesn't have a special parameter, it's just an average digit/integer.
Reply
#3

You should be using d or i for the sscanf string.
Reply
#4

I was looking into that. When I compared this with other codes (the sscanf part), it looked right. Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)