View Single Post
(-DR-)GrammerNatzi
Senior Member
Join Date: Jun 2009
Old 08-11-2009 , 23:20   Re: [L4D] Item Buy System
Reply With Quote #254

Quote:
Originally Posted by symbiant View Post
I have been reading this thread and I noticed that people are having issues with points not clearing as intended. I am new with SourcePawn but I have some prior programming experience. After looking around the code and on the internet I think I have an easy way to clear the points that may work.
If you clear the points at the two critical times:

* When a player connects
* When a map loads(but with a check to prevent issues with versus)

then players should never be able to enter a game with points.

To do this, use the public function OnClientPutInServer to run logic when a player connects to the server. When the function is called you should be given their clientID. Just use this to set that new player's points to Zero.

As for clearing points when the map loads, use hook game_newmap to call an action. The action should run a check to see if this is the first round. To do this, there should be a global variable(still not sure if sourcePawn has something like this) that stores the last map the server had loaded. If the variable(lets call it vs_round_map) equals the ConVar host_map then it will not clear players points. This will allow players to keep their points between rounds on the same map. If vs_round_map doesn't equal host_map then every players points will be set to zero and vs_round_ map will be set equal to host_map. This should allow coop and vs play. As for survival, you could add a check to the bool to see if the game is survival and clear points everytime game_newmap hooks. The bool would look something like this:

(vs_round_map != host_map)||(mp_gamemode = survival)
**I know this isn't how it would look but you get the idea

When the above is TRUE then all points are cleared and vs_round_map is set to host_map

Hopefully this works, the logic seems sound to me(not sure since I am still new to sourcePawn)

Thanks for the awesome mod.

PS: sorry for the long post.
Thanks, but I already tried clearing points on map load. For some reason it wouldn't work. It probably has to do with the way L4D was coded.
(-DR-)GrammerNatzi is offline