DCMD:Nos/Repair - 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: DCMD:Nos/Repair (
/showthread.php?tid=369936)
DCMD:Nos/Repair -
Mustang[GTS] - 18.08.2012
anywone have the code for /nos and /repair pleas?
Re: DCMD:Nos/Repair -
RanSEE - 18.08.2012
BTW, You must learn scripting yourself, instead of making 3-4 command request thread everyday.
pawn Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!PlayerInfo[playerid][pLoggedIn]) return 0;
pawn Код:
dcmd_fix(playerid, params[])
{
new id;
if (sscanf(params, "u", id)) { id = playerid; }
if (id == INVALID_PLAYER_ID) { SendClientMessage(playerid, COLOR_RED, "* /repair: Invalid player"); }
else
{
new veh = GetPlayerVehicleID(id);
if (veh)
{
RepairVehicle(veh);
if (playerid != id) { SendClientMessage(playerid, COLOR_GREEN, "Repaired vehicle"); }
SendClientMessage(id, COLOR_GREEN, "Your vehicle was repaired");
}
else { SendClientMessage(playerid, COLOR_RED, "That player is currently not in a vehicle"); }
}
return 1;
}
pawn Код:
dcmd_nos(playerid, params[])
{
new id;
if (sscanf(params, "u", id)) { id = playerid; }
if (id == INVALID_PLAYER_ID) { SendClientMessage(playerid, COLOR_RED, "* /nos: Invalid player"); }
else
{
new veh = GetPlayerVehicleID(id);
if (veh)
{
AddVehicleComponent(veh, 1010);
if (playerid != id) { SendClientMessage(playerid, COLOR_GREEN, "Added nos to vehicle"); }
SendClientMessage(id, COLOR_GREEN, "Added nos to vehicle");
}
else { SendClientMessage(playerid, COLOR_RED, "That player is currently not in a vehicle"); }
}
return 1;
}
Re: DCMD:Nos/Repair -
Dan. - 18.08.2012
Quote:
Originally Posted by RanSEE
BTW, You must learn scripting yourself, instead of making 3-4 command request thread everyday.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { if (!PlayerInfo[playerid][pLoggedIn]) return 0;
pawn Код:
dcmd_nos(playerid, params[]) { new id; if (sscanf(params, "u", id)) { id = playerid; }
if (id == INVALID_PLAYER_ID) { SendClientMessage(playerid, COLOR_RED, "* /nos: Invalid player"); } else { new veh = GetPlayerVehicleID(id); if (veh) { AddVehicleComponent(veh, 1010); if (playerid != id) { SendClientMessage(playerid, COLOR_GREEN, "Added nos to vehicle"); } SendClientMessage(id, COLOR_GREEN, "Added nos to vehicle"); } else { SendClientMessage(playerid, COLOR_RED, "That player is currently not in a vehicle"); } } } return 1;
pawn Код:
dcmd_fix(playerid, params[]) { new id; if (sscanf(params, "u", id)) { id = playerid; }
if (id == INVALID_PLAYER_ID) { SendClientMessage(playerid, COLOR_RED, "* /repair: Invalid player"); } else { new veh = GetPlayerVehicleID(id); if (veh) { RepairVehicle(veh); if (playerid != id) { SendClientMessage(playerid, COLOR_GREEN, "Repaired vehicle"); } SendClientMessage(id, COLOR_GREEN, "Your vehicle was repaired"); } else { SendClientMessage(playerid, COLOR_RED, "That player is currently not in a vehicle"); } } return 1; }
|
RanSEE, why do you need to use sscanf in that code? That's not needed at all, just making the code slower and longer. I'm not even sure if your code will work.