[Include] Cops
#15

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Yeah I see what you mean I guess I overlooked this line.
Код:
if(e_cops[k][copid] != npcid) continue;
Anyways that brings me to another point. You can eliminate most of your loops which find the correct NPC very easily.
All you need to do is create a reference array.

Код:
g_CopReferences[MAX_PLAYERS] = { -1, ... };
Then what you do is when creating an NPC simply set copid to the index of NPCID

Код:
e_cops[i][copid] = FCNPC_Create(name);
 g_CopReferences[e_cops[i][copid]] = i;
Now all those loops become this.

Old way
Код:
    for(new i = 0; i < MAX_COPS; i++)
    {
        if(!IsCopValid(i) || e_cops[i][copid] != npcid) continue;
        CallLocalFunction("OnCopDeath", "iii", i, killerid, reason);
    }


New way
Код:
// Yes this is a cop!
if(g_CopReferences[npcid] != -1)
      CallLocalFunction("OnCopDeath", "iii", g_CopReferences[npcid], killerid, reason);
Ok thank you will update once im on the pc
Reply


Messages In This Thread
Cops AI - by Lokii - 23.01.2019, 15:00
Re: Cops - by Pottus - 23.01.2019, 15:34
Re: Cops - by Lokii - 23.01.2019, 15:51
Re: Cops - by Hazon - 23.01.2019, 18:27
Re: Cops - by Lokii - 23.01.2019, 18:45
Re: Cops - by Lucky13 - 23.01.2019, 19:27
Re: Cops - by Lokii - 23.01.2019, 19:28
Re: Cops - by N0FeaR - 23.01.2019, 20:24
Re: Cops - by Lokii - 23.01.2019, 20:27
Re: Cops - by Pottus - 24.01.2019, 18:05
Re: Cops - by Lokii - 25.01.2019, 15:53
Re: Cops - by codExpert - 25.01.2019, 16:01
Re: Cops - by Lokii - 25.01.2019, 16:05
Re: Cops - by Pottus - 25.01.2019, 20:26
Re: Cops - by Lokii - 25.01.2019, 20:33
Re: Cops - by Lokii - 28.01.2019, 12:55

Forum Jump:


Users browsing this thread: 1 Guest(s)