Sscanf help. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Sscanf help. (
/showthread.php?tid=383351)
Sscanf help. -
tsonn1 - 07.10.2012
Hi!
I need help with this command:
pawn Код:
CMD:veh(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if (KasutajaInfo[playerid][pAdmin] < 7)
{
SendClientMessage(playerid, COLOR_GRAD1, "Sa ei saa seda kдsklust kasutada.");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "KASUTUS: /auto [carid] [color1] [color2]");
return 1;
}
new car;
car = strval(tmp);
if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GREY, "Vehicle Number can't be below 400 or above 611!"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "KASUTUS: auto [carid] [color1] [color2]");
return 1;
}
new color1;
color1 = strval(tmp);
if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_GREY, "Color Number can't be below 0 or above 126!"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "KASUTUS: auto [carid] [color1] [color2]");
return 1;
}
new color2;
color2 = strval(tmp);
if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_GREY, "Color Number can't be below 0 or above 126!"); return 1; }
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
new carid = CreateVehicle(car, X,Y,Z, 0.0, color1, color2, 60000);
CreatedCars[CreatedCar] = carid;
CreatedCar++;
format(string, sizeof(string), "Vehicle %d spawned.", carid);
SendClientMessage(playerid, COLOR_GREY, string);
}
return 1;
}
I need the command to use sscanf instead of strval n stuff.
Re: Sscanf help. -
tsonn1 - 07.10.2012
Anyone?
Re: Sscanf help. -
Chriham3 - 07.10.2012
pawn Код:
CMD:veh(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if (KasutajaInfo[playerid][pAdmin] < 7) return SendClientMessage(playerid, COLOR_GRAD1, "Sa ei saa seda kдsklust kasutada.");
new car, col1, col2, string[126];
if(sscanf(params, "iii", car, col1, col2)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: [carid] [color1] [color2]");
if(car < 400 || car > 611) return SendClientMessage(playerid, COLOR_GREY, "Vehicle number can't be below 400 or above 611!");
if(col1 < 0 || col1 > 126) return SendClientMessage(playerid, COLOR_GREY, "Color number can't be below 0 or above 126!");
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
new carid = CreateVehicle(car, X,Y,Z, 0.0, col1, col2, 60000);
format(string, sizeof(string), "Vehicle %d spawned.", carid);
SendClientMessage(playerid, COLOR_GREY, string);
}
return 1;
}
You can use if(....) return SendClientMessage(playerid, -1, "....");
instead of if(....) { SendClientMessage(playerid, -1, "...."); return 1; }
as it's easier.