View Single Post
LenHard
Senior Member
Join Date: Jan 2016
Old 05-15-2018 , 18:34   Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #5

Quote:
Originally Posted by Crasher_3637 View Post
You have the right idea but I see a lot of things wrong with your code.

Here are some notes about your code that you should take in:

1. If you're not passing any data on a timer handle, you don't need to put "INVALID_HANDLE" in there. Just simply use an underscore like this: CreateTimer(1.0, Timer_Callback, _, TIMER_REPEAT);
2. ++i is equivalent to i + 2. You should be using i++ instead.
3. Change the following:

PHP Code:
char[] sWeapon = new char[32];
GetEdictClassname(iWeaponsWeapon32); 
To the following:

PHP Code:
char sWeapon[32];
GetEdictClassname(iWeaponsWeaponsizeof(sWeapon)); 
4. You already assigned "g_iWeapon" to 0 in your global declaration. No need to do it again on OnMapStart(). Also, simply declaring it as "int g_iWeapon;" is basically saying that it's already 0.
5. You can make the following a lot easier by changing it from:

PHP Code:
if (sWeapon[7] != 'a' && sWeapon[8] != 'k'
To the following:

PHP Code:
if (StrContains(sWeapon"ak47"false) != -1
1. Would it change anything?
2. I tested it, and the output is the same as i++ (what it's doing is incrementing by 1 + i rather than i + 1)
3. I don't see the need for that? It functions the same way
4. I thought global variables wouldn't reset on map starts?
5. My way is more efficient but I can see why.
__________________
LenHard is offline