PDA

View Full Version : Dod_checkpoint


h0_noMan
12-30-2007, 08:00 PM
This plugins is now completly tested and works fine.

I am a fan of KZ maps and i wanted a plugins to add the possibility to save a location and move to this location after (when you failed a jump for example)

CHANGELOG

v1.1 :
- Added an unblock command to move if you are blocked
- Simplyfing some code (array)

v1.2 :
- Removed the unblock command
- add_checkpoint now add only location that are fine (you shouldnt be blocked in a wall)
- The language can be changed in the SMA by changing the value of language

-----------

CVAR :
dod_checkpoint 1|0 // Enable/Disable the mod

-----------

Console commands:
add_checkpoint // Save the player's location
go_checkpoint // Move the player to his last saved checkpoint

Tested on AMX Mod X 1.80

Thanks for suggestions and comments.

=|[76AD]|= TatsuSaisei
12-31-2007, 04:28 PM
one of the few minor things I noticed was this habit you have of using -1 during a return.. and then checking for it later... while this IS valid and DOES work.. there is a cleaner method...

instead of retunring -1 when not stuck ... return 0 (so the only possible returns are 1 and 0) and then when you "check" the return value in your if...


if(dod_stucked(id)==-1)


can be changed to


if(!dod_stucked(id))


which is the same as
if(dod_stucked(id)== 0)


and the opposite

if(dod_stucked(id))


is the same as

if(dod_stucked(id)== 1)


The way IF works is that a statement is TRUE when it is ANY value OTHER then 0 and FALSE only when it is equal to 0

so then down in the bottom of the plugin you could do this...

if(!get_cvar_num("dod_checkpoint"))

as opposed to
if(get_cvar_num("dod_checkpoint")==0)

Personally the only time I would use == is when I am looking for a specific value other then 0 or not 0 ...

good clean code though....

{DwP} 325th ABN
01-04-2008, 02:38 AM
ill give it a run if tatsu says clean im in