Megaphone command
#1

pawn Код:
if(strcmp(cmd, "/megaphone", true) == 0 || strcmp(cmd, "/m", true) == 0)
    {
        new tmpcar = GetVehicleModel(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_GRAD2, "USAGE: (/m)egaphone [megaphone chat]");
            return 1;
        }
        if (gTeam[playerid] != 2)
        {
            SendClientMessage(playerid, COLOR_GRAD2, "  you are not part of a team");
            return 1;
        }
        if(!IsACopCar(tmpcar))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "  you are not in a police vehicle");
            return 1;
        }
        else
        {
        format(string, sizeof(string), "[Officer %s:o< %s]", sendername, result);
        ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
        printf("%s", string);
        return 1;
        }
    }
IsACopCar:
pawn Код:
public IsACopCar(carid)
{
    if((carid >= 35) && (carid <= 60))
    {
        return 1;
    }
    return 0;
}
Taken out of PenSF

I need to know why the carid is 35 - 60, while the vehicle ID's for the police cars are 596-599 & 601.
The command also tells me that "I'm not in a police vehicle". While I am.

It's PenSF so yeah.. It might not be 0.3 compatible. Could anyone tell me if this has any incompatibility?
Reply
#2

Quote:

Taken out of PenSF

I need to know why the carid is 35 - 60, while the vehicle ID's for the police cars are 596-599 & 601.
The command also tells me that "I'm not in a police vehicle". While I am.

It's PenSF so yeah.. It might not be 0.3 compatible. Could anyone tell me if this has any incompatibility?

The ID's 35 - 60 represents the VEHICLE ID, while 596-599 & 601 represents the MODEL ID.
Reply
#3

Ah.. Annoying thing is that I cannot find a proper list of the Vehicle ID's.
Reply
#4

There's no such thing as a list of vehicle ID's. It depends on what car is loaded first on your server.

For example:

pawn Код:
CreateVehicle(..) //Vehicle ID 1
CreateVehicle(..) //Vehicle ID 2
CreateVehicle(..) //Vehicle ID 3
//And so on...
Note that if you are using filterscripts, the vehicles within a filterscript load before your gamemode, therefore the vehicle ID's will start with the ones in the filterscript.
Reply
#5

Ohhh alright. Then I have one thing to say.. CRAP. So I'll have to get the vehicle ID out of the server?

PS: Could this fix it?

pawn Код:
if(strcmp(cmd, "/megaphone", true) == 0 || strcmp(cmd, "/m", true) == 0)
    {
        new tmpcar = GetVehicleModel(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_GRAD2, "USAGE: (/m)egaphone [megaphone chat]");
            return 1;
        }
        else if (gTeam[playerid] != 2)
        {
            SendClientMessage(playerid, COLOR_GRAD2, "  you are not part of a team");
            return 1;
        }
        else if(!(tmpcar == 427) || !(tmpcar == 490) || !(tmpcar == 523) || !(tmpcar == 528) || !(tmpcar == 596) || !(tmpcar == 597) || !(tmpcar == 598) || !(tmpcar == 599) || !(tmpcar == 601))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "  you are not in a police vehicle");
            return 1;
        }
        else
        {
        format(string, sizeof(string), "[Officer %s:o< %s]", sendername, result);
        ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
        printf("%s", string);
        return 1;
        }
    }
Reply
#6

Just use vehicle models.. 3 cop cars can be ruled out with 3 vehicle models, whereas if you are using vehicle ID's, they take more time because you would have more than 3 police vehicles in your server.
Reply
#7

Quote:
Originally Posted by Conroy
Just use vehicle models.. 3 cop cars can be ruled out with 3 vehicle models, whereas if you are using vehicle ID's, they take more time because you would have more than 3 police vehicles in your server.
I just did that, but it still says the same thing. "You are not in a police vehicle"
Reply
#8

Where you put 'if(!(tmpcar == 427)', you don't need an extra pair of brackets, so remove that line and use this:

pawn Код:
else if(tmpcar != 427) || tmpcar != 490 || tmpcar != 523 || tmpcar != 528 || tmpcar != 596 || tmpcar != 597 || tmpcar != 598) || tmpcar != 599 || tmpcar != 601)
If it still doesn't work then I'll recode you a new one.
Reply
#9

Код:
D:\DOCUME~1\Rizky\BUREAU~1\PENSF.pwn(10543) : error 029: invalid expression, assumed zero
D:\DOCUME~1\Rizky\BUREAU~1\PENSF.pwn(10543) : warning 215: expression has no effect
D:\DOCUME~1\Rizky\BUREAU~1\PENSF.pwn(10543) : error 001: expected token: ";", but found ")"
D:\DOCUME~1\Rizky\BUREAU~1\PENSF.pwn(10543) : error 029: invalid expression, assumed zero
D:\DOCUME~1\Rizky\BUREAU~1\PENSF.pwn(10543) : fatal error 107: too many error messages on one line
Reply
#10

Sorry, forgot to remove a bracket, try this:

pawn Код:
else if(tmpcar != 427 || tmpcar != 490 || tmpcar != 523 || tmpcar != 528 || tmpcar != 596 || tmpcar != 597 || tmpcar != 598) || tmpcar != 599 || tmpcar != 601)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)