Command works only in cop car
#1

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;
    }
Reply
#2

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?
Reply
#3

http://pastebin.com/d2ead341f
Reply
#4

castle.. my PAWNO did crashed when i put ur code...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)