Need help with dcmd.
#1

Hey, so i made a car cmd, but when i use it, it gives me SERVER: Unknown Command

Please help !

Here is the code.

pawn Код:
dcmd_car(playerid,params[]) {
        new String[256], tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index); tmp3 = strtok(params,Index);
        if(!strlen(tmp)) return SendClientMessage(playerid, red, "Use: /car [Modelid/Name] [colour1] [colour2]");
        new car, colour1, colour2;
        car = GetVehicleModelIDFromName(tmp);
        if(car < 400 || car > 611) return  SendClientMessage(playerid, red, "Invalid Vehicle || Use 400-611 || Or Type Car Name");
        if(car == 425) return  SendClientMessage(playerid, red, "Invalid Vehicle || Use 400-611 || Or Type Car Name");
        if(car == 520) return  SendClientMessage(playerid, red, "Invalid Vehicle || Use 400-611 || Or Type Car Name");
        if(car == 432) return  SendClientMessage(playerid, red, "Invalid Vehicle || Use 400-611 || Or Type Car Name");
        if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
        if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
        new Float:X,Float:Y,Float:Z, Float:Angle,int1;  GetPlayerPos(playerid, X,Y,Z);  GetPlayerFacingAngle(playerid,Angle);   int1 = GetPlayerInterior(playerid);
        vCar[playerid] = CreateVehicle(car, X+3,Y,Z, Angle, colour1, colour2, -1); LinkVehicleToInterior(vCar[playerid],int1);
        if(vCar[playerid] != -1)
        {
            DestroyVehicle(vCar[playerid]);
        }
        PutPlayerInVehicle(playerid, vCar[playerid], 0);
        new str[128];
        format(str, sizeof(str), "[Car Spawn] You Spawned || %s || ID:%d", VehicleNames[car-400], car, colour1, colour2);
        SendClientMessage(playerid, 0xFFFFFF, String);
        return 1;
}
Reply
#2

Something in the command is causing it to return 0, could you try and find out what it is?

And also, DCMD + strtok are outdated functions, it's better if you use ZCMD + sscanf.

Another thing, you don't need a 256 size array for the 'tmp' strings.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)