Help need - 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: Help need (
/showthread.php?tid=585853)
Help need -
andreistalker - 17.08.2015
I have a command /towcar when i write /towcar 1 for car 1 is working but when i write /towcar 2 for car 2 is saying: UNKNOW COMMAND
PHP код:
CMD:tracteaza(playerid, params[])
{
new string[144];
new CARID;
if(GetPlayerMoney(playerid) < 10) return SendClientMessage(playerid, -1, "Nu ai indeajuns bani!");
if(sscanf(params, "u", CARID)) return SendClientMessage(playerid, -1, "{FF0000}Folosire: /tracteaza [MASINA(1-2)]");
if(P_Data[playerid][pCar1] == 0 && P_Data[playerid][pCar2] == 0) return SendClientMessage(playerid, -1, "Nu ai masina!");
if(CARID > 3) return 1;
if(CARID == 1)
{
if(P_Data[playerid][pCar1] == 1)
{
foreach(Player, i)
{
if(IsPlayerInVehicle(i, masina[playerid]) == 1) return SendClientMessage(playerid, -1, "Masina in folosinta!");
}
DestroyVehicle(masina[playerid]);
masina[playerid] = CreateVehicle(P_Data[playerid][pCarID1], P_Data[playerid][pCarX1], P_Data[playerid][pCarY1], P_Data[playerid][pCarZ1], P_Data[playerid][pCarR1], P_Data[playerid][pCarColor11], P_Data[playerid][pCarColor21], -1);
P_Data[playerid][pCarKey1] = masina[playerid];
format(string, sizeof(string), "%s a fost tractat la locul de parcare!", VehicleNames[P_Data[playerid][pCarID1]-400]);
SendClientMessage(playerid, -1, string);
}
}
if(CARID == 2)
{
if(P_Data[playerid][pCar2] == 1)
{
foreach(Player, i)
{
if(IsPlayerInVehicle(i, masina2[playerid]) == 1) return SendClientMessage(playerid, -1, "Masina in folosinta!");
}
DestroyVehicle(masina2[playerid]);
masina2[playerid] = CreateVehicle(P_Data[playerid][pCarID2], P_Data[playerid][pCarX2], P_Data[playerid][pCarY2], P_Data[playerid][pCarZ2], P_Data[playerid][pCarR2], P_Data[playerid][pCarColor12], P_Data[playerid][pCarColor22], -1);
P_Data[playerid][pCarKey2] = masina2[playerid];
format(string, sizeof(string), "%s a fost tractat la locul de parcare!", VehicleNames[P_Data[playerid][pCarID2]-400]);
SendClientMessage(playerid, -1, string);
}
}
return 1;
}
Re: Help need -
Mariciuc223 - 17.08.2015
PHP код:
if(sscanf(params, "u", CARID))
Why there you used "u" that mean user ... use "d" or "i" for integers .
Re: Help need -
Beckett - 17.08.2015
The 'u' specifier detects for connected players not an integer. Use 'i' specifier instead.
From this:
pawn Код:
if(sscanf(params, "u", CARID)) return SendClientMessage(playerid, -1, "{FF0000}Folosire: /tracteaza [MASINA(1-2)]");
To this:
pawn Код:
if(sscanf(params, "i", CARID)) return SendClientMessage(playerid, -1, "{FF0000}Folosire: /tracteaza [MASINA(1-2)]");
Re: Help need -
ZToPMaN - 17.08.2015
CMD:tracteaza(playerid, params[])
{
new string[144];
new CARID;
if(GetPlayerMoney(playerid) < 10) return SendClientMessage(playerid, -1, "Nu ai indeajuns bani!");
if(sscanf(params, "d", CARID)) return SendClientMessage(playerid, -1, "{FF0000}Folosire: /tracteaza [MASINA(1-2)]");
if(P_Data[playerid][pCar1] == 0 && P_Data[playerid][pCar2] == 0) return SendClientMessage(playerid, -1, "Nu ai masina!");
if(CARID > 3) return 1;
if(CARID == 1)
{
if(P_Data[playerid][pCar1] == 1)
{
foreach(Player, i)
{
if(IsPlayerInVehicle(i, masina[playerid]) == 1) return SendClientMessage(playerid, -1, "Masina in folosinta!");
}
DestroyVehicle(masina[playerid]);
masina[playerid] = CreateVehicle(P_Data[playerid][pCarID1], P_Data[playerid][pCarX1], P_Data[playerid][pCarY1], P_Data[playerid][pCarZ1], P_Data[playerid][pCarR1], P_Data[playerid][pCarColor11], P_Data[playerid][pCarColor21], -1);
P_Data[playerid][pCarKey1] = masina[playerid];
format(string, sizeof(string), "%s a fost tractat la locul de parcare!", VehicleNames[P_Data[playerid][pCarID1]-400]);
SendClientMessage(playerid, -1, string);
}
}
if(CARID == 2)
{
if(P_Data[playerid][pCar2] == 1)
{
foreach(Player, i)
{
if(IsPlayerInVehicle(i, masina2[playerid]) == 1) return SendClientMessage(playerid, -1, "Masina in folosinta!");
}
DestroyVehicle(masina2[playerid]);
masina2[playerid] = CreateVehicle(P_Data[playerid][pCarID2], P_Data[playerid][pCarX2], P_Data[playerid][pCarY2], P_Data[playerid][pCarZ2], P_Data[playerid][pCarR2], P_Data[playerid][pCarColor12], P_Data[playerid][pCarColor22], -1);
P_Data[playerid][pCarKey2] = masina2[playerid];
format(string, sizeof(string), "%s a fost tractat la locul de parcare!", VehicleNames[P_Data[playerid][pCarID2]-400]);
SendClientMessage(playerid, -1, string);
}
}
return 1;
}
if you used " U " in sscanf it mean id. ( playerid ) (target id )
if you used " d/i " it mean intger like 1, 2 .....etc
if you used " s " it mean sting ( text ) .