SA-MP Forums Archive
This command isn't working in a copcar. But it should. - 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: This command isn't working in a copcar. But it should. (/showthread.php?tid=400207)



This command isn't working in a copcar. But it should. - Kethrios - 17.12.2012

Hi everybody !

I've a police command, which is "/p record PLAYERID" to see what contain the record of a specific player.
The thing is that, when I coded it, I missed something at the very beginning I guess.

You can use it only in front of the police computer, or in a police car.


pawn Code:

pawn Код:
else if(strcmp(subcmd, "records", true) == 0 || strcmp(subcmd, "computer", true) == 0)
            {
                if(PlayerInfo[playerid][pMember] == FACT_COPS_LS && !PlayerToPoint(5, playerid,1550.79,-1663.25,-9.19) || IsPlayerInAnyVehicle(playerid) && !IsACopCar(GetPlayerVehicleID(playerid)))
                    {SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} You're not in front of the police computer or you're not in a police car."); return 1;}
                tmp=strtok(cmdtext,idx);

For me everything is alright. But still... When a policeman use it in a cop car it says that he's not in front of a police computer or in a cop car.

I have no errors, no warnings, but still, it's buggued o_o


Re : This command isn't working in a copcar. But it should. - Kethrios - 17.12.2012

I'm not a mathematician unfortunatly, this is chinese for me (and I think I understand more chinese than math !).
Is this a problem with the "!" ?


Re : This command isn't working in a copcar. But it should. - Kethrios - 18.12.2012

Ok, I just edited the code with the one you see here, but nothing change..
Can someone provide me some help please ?


Re: This command isn't working in a copcar. But it should. - iggy1 - 18.12.2012

Have you tried debugging it?

Instead of having lots of checks on one line, spread them out and find the problem.

EG:

pawn Код:
if(PlayerInfo[playerid][pMember] == FACT_COPS_LS)
{
    if(!PlayerToPoint(5, playerid,1550.79,-1663.25,-9.19))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(IsACopCar(GetPlayerVehicleID(playerid)))
            {
            }
            else
            {
                printf("<error> Player is not in a cop car");
            {
        }
        else
        {
            print("<error> Player is not in a vehicle");
        }
    }
    else
    {
        print("<error> Player is in range of 1550.79,-1663.25,-9.19");
    }
}
else
{
    printf("<error> Var PlayerInfo[playerid][pMember] == %d", PlayerInfo[playerid][pMember]);
}
It is more code but a million times easier to debug than all in one line. This is just an example you may want that to be structured differently.


Re : This command isn't working in a copcar. But it should. - Kethrios - 18.12.2012

I can't setup it correctly ^^'
I don't want to release the entire code here so.. Can someone even see what is wrong with this one ?


Re : This command isn't working in a copcar. But it should. - Kethrios - 19.12.2012

You gave me a link that only someone who know what he's reading can understand, I'm not an engineer, a mathematician, and in my studies I've no maths since 3 years, so, I've not your level maybe, and I'm not able to undertsand this clearly.