06.07.2014, 02:47
Olб queria mudar esse cуdigo do meu antigo GM de strtok para sscanf para adaptalo no meu novo GM.
pawn Код:
CMD:car(playerid, params[])
{
new tmp2[256], idx, tmp[256], tmp3[256]; tmp = strtok(params,idx), tmp2 = strtok(params,idx); tmp3 = strtok(params,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "{fff78c} Use: /car id/nome");
new car, colour1, colour2;
if(!IsNumeric(tmp)) car = GetVehicleModelIDFromName(tmp); else car = strval(tmp);
if(car < 400 || car > 611) return SendClientMessage(playerid, Vermelho, "ERRO: Modelo de Veнculo Invбlido");
if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
if(MundoMATAMATA[playerid] == false)
{
if(car == 520 || car == 432 || car == 592 || car == 425 || car == 464|| car == 476|| car == 447) return SendClientMessage(playerid, Cinza, "Veнculo liberado somente no mundo Mata Mata {FFFFFF}/Mundos {FFFFFF}!");
}
new LVehicleID, int1; GetPlayerPos(playerid, X,Y,Z); GetPlayerFacingAngle(playerid,Angle); int1 = GetPlayerInterior(playerid);
if(IsPlayerInAnyVehicle(playerid)) {
DestroyVehicle(GetPlayerVehicleID(playerid));
LVehicleID = CreateVehicle(car, X,Y,Z, Angle, colour1, colour2, -1); LinkVehicleToInterior(LVehicleID,int1);
SetVehicleVirtualWorld(LVehicleID ,GetPlayerVirtualWorld(playerid));
PutPlayerInVehicle(playerid,LVehicleID, 0);
new string[256];
format(string, sizeof(string), "{FFFFFF}Seu Veнculo foi criado com sucesso!{fff78c} \"{FFFFFF}%s{fff78c}\" (Modelo: {FFFFFF}%d{fff78c}) (Cores: {FFFFFF}%d / %d{fff78c})", VehicleNames[car-400], car, colour1, colour2);
SendClientMessage(playerid, Amarelo, string);
return 1;
} else {
LVehicleID = CreateVehicle(car, X,Y,Z, Angle, colour1, colour2, -1); LinkVehicleToInterior(LVehicleID,int1);
PlayerInfo[playerid] = LVehicleID;
SetVehicleVirtualWorld(LVehicleID,GetPlayerVirtualWorld(playerid));
PutPlayerInVehicle(playerid,LVehicleID, 0);
new string[256];
format(string, sizeof(string), "{FFFFFF}Seu Veнculo foi criado com sucesso!{fff78c} \"{FFFFFF}%s{fff78c}\" (Modelo: {FFFFFF}%d{fff78c}) (Cores: {FFFFFF}%d / %d{fff78c})", VehicleNames[car-400], car, colour1, colour2);
SendClientMessage(playerid, Amarelo, string);
return 1;
}
}