AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Admin Mark (marks admins with beret or helmet) (https://forums.alliedmods.net/showthread.php?t=56751)

hackziner 06-22-2007 13:56

Re: Admin Mark
 
Hum, really nice plugin :)

Hawk552 06-23-2007 11:27

Re: Admin Mark
 
Code:
    if (equali(modelStr,"gign") )     {         modelID = 0     }     else if (equali(modelStr,"gsg9") )     {         modelID = 1     }     else if (equali(modelStr,"sas") )     {         modelID = 2     }     else if (equali(modelStr,"urban") )     {         modelID = 3     }     else if (equali(modelStr,"vip") )     {         modelID = 4     }     else if (equali(modelStr,"arctic") )     {         modelID = 5     }     else if (equali(modelStr,"guerilla") )     {         modelID = 6     }     else if (equali(modelStr,"leet") )     {         modelID = 7     }     else if (equali(modelStr,"terror") )     {         modelID = 8     }     else         modelID = 9

Terrible. Make a global array which stores all these names, then run a loop checking if it's each one. If it is, set model ID to the iterator's value.

I'm willing to hold this back for this optimization alone. Please do it within a week or I will unapprove this.

kaloszyfer 06-24-2007 10:12

Re: Admin Mark
 
OK, I'll try.

kmal2t 06-24-2007 15:10

Re: Admin Mark
 
Why not just make it as a stock? like:

Code:
switch(get_model(id)) {     case 1: blah blah     case 2: blah blah } stock get_model(id) {     new model[10];     cs_get_user_model(id, model, 9);     if(equal(model, "blahblah"))         return 1;     if(equal(model, "blahblah"))         return 2;     if(equal(model, "blahblah"))         return 3;     return 0; }

btw, the beret looks like a seat cushion on their head lol.

ConnorMcLeod 06-24-2007 17:05

Re: Admin Mark
 
Because this would not optimize the code.

sawce 06-24-2007 21:36

Re: Admin Mark
 
Quote:

Originally Posted by kaloszyfer (Post 494071)
OK, I'll try.

Just butting in here, I really don't see the need to put that function in prethink to begin with.

I would assume just making an array of what model ID they have at the round start would suffice. It might temporarily display the wrong helmet for the remainder of a round if an admin uses a command to force a model change, but that'd be a small price to pay for the overhead reduction.

Lee 06-24-2007 21:53

Re: Admin Mark
 
Quote:

Originally Posted by kmal2t (Post 494195)
Why not just make it as a stock?

To see what stocks actually are - as you evidently have no idea - read this.

kmal2t 06-24-2007 22:55

Re: Admin Mark
 
Eh fine then you can do it like this too:

Code:
#define myNum 3 public myFunc(id) {     new const array[myNum][] = {         "shit0",         "shit1",         "shit2"         };     for(new i=0;i<myNum;i++) {         if(equal(tuna, array[i])) {             shit;         }     } }

This also begs the question, as a GENERAL rule how many ifs would it be before it's a better idea to use a loop instead?

kaloszyfer 06-25-2007 06:28

Re: Admin Mark
 
Plugin updated!

Alka 06-25-2007 07:18

Re: Admin Mark
 
1.Don't use "stock" at get_model(id).
2.like sawce said
Quote:

Originally Posted by sawce
Just butting in here, I really don't see the need to put that function in prethink to begin with.

EDIT:Yes public !


All times are GMT -4. The time now is 06:34.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.