Raised This Month: $51 Target: $400
 12% 

Ski 2 Shop v1.7.1


Post New Thread Reply   
 
Thread Tools Display Modes
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 10-31-2010 , 20:49   Re: Ski 2 Shop v1.6
Reply With Quote #61

Quote:
Originally Posted by ConnorMcLeod View Post
Code:
public NewRound() {     RoundCount++;         CacheCvars();         new players[32], num;     get_players(players, num, "ch");         for (new i = 0; i < num; ++i) {         for (new j = 0; j < sizeof(UserItems[]); ++j) {             if (DURATION[j][duration] == -1) break;
            if (~UserItems[i] & (1 << j)) break;
           
            if (RoundCount == UserRoundStart[i][j] + DURATION[j][duration]) {
                UserItems[i] &= ~(1 << j);
                client_print(i, print_chat, "%L", i, DURATION[j][lostMlStr]);
            }         }     } }

You have to figure out that 'i' is the array position and not the player id




Code:
CheckUserMoney(id, money) {     if (cs_get_user_money(id) < money) {         client_print(id, print_center, "%L", id, "NOT_ENOUGH_MONEY");         return 0;     }     cs_set_user_money(id, cs_get_user_money(id)-money);     return 1; }

Cache money amount wouldn't hurt so you wouldn't have to retrieve it twice
Oh dear this thing still exists? I'll see what I can do with this mess.
Seta00 is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 10-31-2010 , 21:14   Re: Ski 2 Shop v1.6
Reply With Quote #62

Okay, plugin updated with the silly bugs Connor pointed out fixed.
I've also fixed some naming convention, removed unused code left from a custom version, and fixed the enum naming tag mess.
Seta00 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-02-2010 , 11:30   Re: Ski 2 Shop v1.7
Reply With Quote #63

Code:
public OnItemPickup(player) {     if (!HAS_EXTRA_ARMOR(player))         return;         new itemName[17];     read_data(1, itemName, charsmax(itemName));         if (!(equal(itemName, "item_kevlar") || equal(itemName, "item_assaultsuit"))) {         return;     }         cs_set_user_armor(player, 150, (equal(itemName, "item_kevlar")) ? CS_ARMOR_KEVLAR : CS_ARMOR_VESTHELM);     return; }

I think you can register the event so it will be trigger for both items.
Also, if this event is sent, i think you can just set armorvalue since armortype has just been set and purpose of the function is only to raise armor value.
Other thing is that when you already have helmet and you purchase a vest, armorvalue is raised but you still have the helmet, if item message is kevlar your function would change armortype with no reason.
If registering filters ( ..., "1=item_kevlar", "1=item_assaultsuit"), keep the actual method but cache result for item_kevlar, also, your check on item_assaultsuit is false, you forgot '!', and OR should be AND.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 11-02-2010 , 13:53   Re: Ski 2 Shop v1.7
Reply With Quote #64

Quote:
Originally Posted by ConnorMcLeod View Post
Code:
public OnItemPickup(player) {     if (!HAS_EXTRA_ARMOR(player))         return;         new itemName[17];     read_data(1, itemName, charsmax(itemName));         if (!(equal(itemName, "item_kevlar") || equal(itemName, "item_assaultsuit"))) {         return;     }         cs_set_user_armor(player, 150, (equal(itemName, "item_kevlar")) ? CS_ARMOR_KEVLAR : CS_ARMOR_VESTHELM);     return; }

I think you can register the event so it will be trigger for both items.
Also, if this event is sent, i think you can just set armorvalue since armortype has just been set and purpose of the function is only to raise armor value.
Other thing is that when you already have helmet and you purchase a vest, armorvalue is raised but you still have the helmet, if item message is kevlar your function would change armortype with no reason.
If registering filters ( ..., "1=item_kevlar", "1=item_assaultsuit"), keep the actual method but cache result for item_kevlar, also, your check on item_assaultsuit is false, you forgot '!', and OR should be AND.
Okay, the only part I really understood here was " your check on item_assaultsuit is false, you forgot '!', and OR should be AND.", and the code is correct. Notice how I've embraced the whole check in parameters:
if (!(equal(itemName, "item_kevlar") || equal(itemName, "item_assaultsuit"))).

I'm setting the armor type on the callback because the parameter is mandatory on the cstrike native, and there's no "don't change" equivalent:

Code:
enum CsArmorType {     CS_ARMOR_NONE = 0, // no armor     CS_ARMOR_KEVLAR = 1, // armor     CS_ARMOR_VESTHELM = 2 // armor and helmet };

EDIT: Okay, I've read it again and I think I've got it now. I really don't like the registering filters the way they work on AMXx, I prefer to inline the checks. Also, there's no such thing as having the helmet and not the vest on CS.

Last edited by Seta00; 11-02-2010 at 13:59.
Seta00 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-02-2010 , 18:11   Re: Ski 2 Shop v1.7
Reply With Quote #65

About item name check, my bad.
About the helmet without helmet, just meant that when you have helmet + vest, but need some armor (suppose you have 50AP), you just need to buy vest $650 and you have full 100AP vest + helmet, i doubt that helmet itempickup is sent in this situation.
Anyway, set only pev_armorvalue grant you to not remove a player's helmet.
About filter in register_event, that was a suggestion, if it was my plugin i would take the time to test exactly how filter works (i already made tests in the past but i wouldn't be able to tell you the result).
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 11-02-2010 , 18:16   Re: Ski 2 Shop v1.7
Reply With Quote #66

Fair call. Plugin updated to v1.7.1
Seta00 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-02-2010 , 18:50   Re: Ski 2 Shop v1.7
Reply With Quote #67

Ok, approved.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:46.


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