[Help] Some cmd.. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] Some cmd.. (
/showthread.php?tid=160401)
[Help] Some cmd.. -
Maxips2 - 16.07.2010
Okay so, I got this command:
pawn Код:
if (strcmp(cmd, "/loadtrash", true) == 0)
{
if(PlayerInfo[playerid][pJob] == 1)
{
new vehicle = GetPlayerClosestVehicle(5.0, playerid);
if(vehicle)
{
if(IsGarbageTruck(vehicle))
{
Trash[vehicle] += gHasTrash[playerid];
format(string, sizeof(string), "You have loaded %d trash into the trashmaster, trashmaster trash: %d/20", gHasTrash[playerid], Trash[vehicle]);
SCM(playerid, 0x8CFFFFFF, string);
gHasTrash[playerid] = 0;
}
else if(!IsGarbageTruck(vehicle))
{
SCM(playerid, COLOR_GREY, "You can only load trash into garbage trucks.");
}
}
else
{
SCM(playerid, COLOR_GREY, "You are not near a garbage truck.");
}
}
else
{
SCM(playerid, COLOR_GREY, "* You are not a garbage collector.");
}
return 1;
}
And I got a problem with it.
The problem is.. when I type the cmd and I'm near a garbage truck or not, it gives me this message:
"You can only load trash into garbage trucks."
Re: [Help] Some cmd.. -
DJDhan - 16.07.2010
Try this code:
Код:
if (strcmp(cmdtext, "/loadtrash", true) == 0)
{
if(PlayerInfo[playerid][pJob] == 1)
{
new vehicle = GetPlayerClosestVehicle(5.0, playerid);
if(vehicle)
{
if(!IsGarbageTruck(vehicle)) return SCM(playerid, COLOR_GREY, "You can only load trash into garbage trucks.");
Trash[vehicle] += gHasTrash[playerid];
format(string, sizeof(string), "You have loaded %d trash into the trashmaster, trashmaster trash: %d/20", gHasTrash[playerid], Trash[vehicle]); SCM(playerid, 0x8CFFFFFF, string);
gHasTrash[playerid] = 0;
}
else return SCM(playerid, COLOR_GREY, "You are not near a garbage truck.");
}
else return SCM(playerid, COLOR_GREY, "* You are not a garbage collector.");
}
Re: [Help] Some cmd.. -
Maxips2 - 16.07.2010
Still the same
Re: [Help] Some cmd.. -
ikey07 - 16.07.2010
try this
pawn Код:
if (strcmp(cmd, "/loadtrash", true) == 0)
{
if(PlayerInfo[playerid][pJob] == 1)
{
new vehicle = GetPlayerClosestVehicle(5.0, playerid);
if(vehicle)
{
if(IsGarbageTruck(vehicle))
{
Trash[vehicle] += gHasTrash[playerid];
format(string, sizeof(string), "You have loaded %d trash into the trashmaster, trashmaster trash: %d/20", gHasTrash[playerid], Trash[vehicle]);
SCM(playerid, 0x8CFFFFFF, string);
gHasTrash[playerid] = 0;
}
else
{
SCM(playerid, COLOR_GREY, "You can only load trash into garbage trucks.");
}
}
else
{
SCM(playerid, COLOR_GREY, "You are not near a garbage truck.");
}
}
else
{
SCM(playerid, COLOR_GREY, "* You are not a garbage collector.");
}
return 1;
}
Re: [Help] Some cmd.. -
DJDhan - 16.07.2010
Try it now:
Код:
if (strcmp(cmdtext, "/loadtrash", true) == 0)
{
if(PlayerInfo[playerid][pJob] != 1) return SCM(playerid, COLOR_GREY, "* You are not a garbage collector.");
new vehicle = GetPlayerClosestVehicle(5.0, playerid);
if(vehicle)
{
if(!IsGarbageTruck(vehicle)) return SCM(playerid, COLOR_GREY, "You can only load trash into garbage trucks and there seems to be none around you.");
Trash[vehicle] += gHasTrash[playerid];
format(string, sizeof(string), "You have loaded %d trash into the trashmaster, trashmaster trash: %d/20", gHasTrash[playerid], Trash[vehicle]); SCM(playerid, 0x8CFFFFFF, string);
gHasTrash[playerid] = 0;
}
return 1;
}
Re: [Help] Some cmd.. -
Maxips2 - 16.07.2010
Still the same
Re: [Help] Some cmd.. -
Joe_ - 16.07.2010
pawn Код:
if (strcmp(cmdtext, "/loadtrash", true) == 0)
{
if(PlayerInfo[playerid][pJob] != 1) return SCM(playerid, COLOR_GREY, "* You are not a garbage collector.");
new vehicle = GetPlayerClosestVehicle(5.0, playerid);
if(vehicle)
{
if(GetVehicleModel(vehicle) != TRASHMASTER_MODEL_ID) return SCM(playerid, COLOR_GREY, "You can only load trash into garbage trucks and there seems to be none around you.");
Trash[vehicle] += gHasTrash[playerid];
format(string, sizeof(string), "You have loaded %d trash into the trashmaster, trashmaster trash: %d/20", gHasTrash[playerid], Trash[vehicle]); SCM(playerid, 0x8CFFFFFF, string);
gHasTrash[playerid] = 0;
}
return 1;
}
Replace - TRASHMASTER_MODEL_ID with the modelid.
Re: [Help] Some cmd.. -
Maxips2 - 16.07.2010
Still the same :/
Re: [Help] Some cmd.. -
DJDhan - 16.07.2010
Show the function :
Код:
IsGarbageTruck(vehicleid)
Re: [Help] Some cmd.. -
Maxips2 - 16.07.2010
pawn Код:
public IsGarbageTruck(carid)
{
if(carid >= 81 && carid <= 84)
{
return 1;
}
return 0;
}