Killstreak plugin - problem
Hi,
It's my first post ever here, on Allied Modders, today is also the first time I started writing my own plugin. This forum is quite helpful for most of the cases but now it seems I can't find the answer in other threads/help requests/approved plugins. That's why I need Your help. I've started writing Killstreak Plugin which (hopefully) is going to look like this: If players' killstreak is equal or more than 5 he gets +2 points for each kill, if players' killstreak is equal or more than 10 he gets +3 points for each kill. In the end there's a HUD message with current killstreak count. Everything is working great except for one thing.. Any kill made by every player on the server raises the killstreak counter thus making everyone having a killstreak. I've been trying to find the mistake for like an hour and it seems I'm either blind or just did something wrong from the very beginning. Sorry for long post and thanks in advance for some guides/help. Wall of text - off, here's another one: PHP Code:
|
Re: Killstreak plugin - problem
PHP Code:
|
Re: Killstreak plugin - problem
Some of your variables didn't really need to be global, therefor I moved them inside of the function.
Code:
Code:
Code:
You could also do this but then it wouldn't stop at +2, it could continue forever. Code:
You could of course solve that by doing this which is compact and readable. Code:
In the end coding is so much personal preference, so you decide which option suits you best. Here's an example that should work: Code:
|
Re: Killstreak plugin - problem
Thank you for such fast response ! :)
I guess it was mostly about this? PHP Code:
PHP Code:
And thanks for kind words, trying to do my best :) ++ Found another problem, this time with HUD Message. Since it didn't count killstreak at all I've changed it from: PHP Code:
PHP Code:
(I kill = shows my kills, someone kills = show its kills) |
Re: Killstreak plugin - problem
The g_Kills[33] creates 33 an array of variables that are separated.
We use these to store the 32 players in index 1-32, index 0 is never used for readability. We don't use id-1 just to save some memory. This is of course instead of using separate variables for everyone, because that would just be stupid. For example: Code:
So when g_Kills[id] is called, and lets say id is 4 then the 4th index of the variable will be read. The limit of the variable is way more than what you will achieve before a mapchange or the server crashes by random. |
Re: Killstreak plugin - problem
Thanks for explanation :)
Any ideas on this HUD message thing? |
Re: Killstreak plugin - problem
Sorry I didn't read that.
Well since killer is an argument that is sent through the message "DeathMsg" you cannot use it like before. The best way would be to loop through players and check which are connected/alive (whichever you want) and then display it to everyone. You only have to loop the actual show_hudmessage(), not set_hudmessage. Here are some examples, they all work: Code:
The outcome is the same, it's just another way of doing it. Code:
I suggest you longen the time of the HudMessage and shorten the set_task() interval. You could add a second HudMessage to update every time the kills get updated instead. If the channel is the same on both messages the new one will overwrite the old one: Code:
|
Re: Killstreak plugin - problem
Wow !! Just read Up the Black Rose's Explanation :) Learnt alot :)
Tysm Black Rose for awesome explanation.And Plugin is Nice as well. Edit : Have 1 question in mind .. what is the actual difference between MSG_BROADCAST and MSG_ALL Searched a little it says the difference is the streams of sending message . Didnt understand. Can any1 give a quick info regarding streams and when to use _BROADCAST and When _ALL ? |
Re: Killstreak plugin - problem
Quote:
Code:
#define MSG_BROADCAST 0 // Unreliable to allI'm sure you could find a more detailed explanation by one of the top coders if you search the forum. A rule of thumb is to use BROADCAST and ONE_UNRELIABLE unless it's absolutely critical that the message reaches the client. |
Re: Killstreak plugin - problem
I appreciate all the help and tips Black Rose, these are very useful, thank you :)
So.. using second method which is: PHP Code:
++ When I'm alone on the server and kill the bots it works just fine but when any other real player joins and gets its killstreak it just goes crazy. |
| All times are GMT -4. The time now is 16:00. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.