Command works only in cop car - 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: Command works only in cop car (
/showthread.php?tid=74020)
Command works only in cop car -
krisis32 - 19.04.2009
Hello!
I got this code and i want it to make its only work in cop car...
pawn Код:
if(strcmp(cmd, "/megaphone", true) == 0 || strcmp(cmd, "/m", true) == 0)
{
LimitGlobalChatRadius(50); // i think 25-35 is best
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: (/m)egaphone [text]");
return 1;
}
format(string, sizeof(string), "(POLICE MEGAPHONE) Officer %s: %s!!", sendername, result);
ProxDetector(30.0, playerid, string,COLOR_BLUE,COLOR_BLUE,COLOR_BLUE,COLOR_BLUE,COLOR_BLUE);
printf("%s", string);
}
return 1;
}
This one didnt work for me:
pawn Код:
if(strcmp(cmd, "/megaphone", true) == 0 || strcmp(cmd, "/m", true) == 0)
{
LimitGlobalChatRadius(50); // i think 25-35 is best
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: (/m)egaphone [text]");
return 1;
}
new tmpcar = GetPlayerVehicleID(playerid);
if (!IsACopCar(tmpcar) && GetPlayerInterior(playerid) == 0)
{
SendClientMessage(playerid, COLOR_RED, " You are not in a cop car!");
return 1;
}
format(string, sizeof(string), "(POLICE MEGAPHONE) Officer %s: %s!!", sendername, result);
ProxDetector(30.0, playerid, string,COLOR_BLUE,COLOR_BLUE,COLOR_BLUE,COLOR_BLUE,COLOR_BLUE);
printf("%s", string);
}
return 1;
}
Re: Command works only in cop car -
Weirdosport - 19.04.2009
Why didn't you leave strtok as a stock? Looks like you've dumped it in with your code and it's v. hard to read.
!IsACopCar(tmpcar) <-- what's this?
Re: Command works only in cop car -
Castle - 19.04.2009
http://pastebin.com/d2ead341f
Re: Command works only in cop car -
krisis32 - 19.04.2009
castle.. my PAWNO did crashed when i put ur code...