Raised This Month: $ Target: $400
 0% 

Proofreading


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-20-2009 , 10:15   Re: Proofreading
Reply With Quote #2

PHP Code:
new const message [] =
{
"If you see this that means that this server has not set classinfo.html into their Warfighter directory, Please contact a administrator."


The bracket is unnecessary and you can also avoid using the "new" operator and instead just use const.

PHP Code:
new Float:WMspeed 300.0;
new 
Float:JFspeed 400.0;
new 
Float:SBspeed 350.0;
new 
Float:STspeed 250.0;
new 
Float:AHspeed 300.0;
new 
Float:ROspeed 325.0;
new 
Float:SSspeed 275.0
Consider using an array declared with an enumeration, something like this:

PHP Code:
enum SPEED
{
    
WM 0,
    
JF,
    
SB,
    
ST,
    
AH,
    
RO,
    
SS
}

new 
Float:gSpeeds[SPEED] = 
{
    
300.0,
    
400.0,
    
350.0,
    
250.0,
    
300.0,
    
325.0,
    
275.0

This makes it easier to read, helps you type-check and also allows you to iterate through them.

PHP Code:
public plugin_init() 
{

register_plugin ("WarFighter Mod""1.1" "OneMoreLevel")

register_clcmd"say /class","plugin_classmenu");
register_clcmd"say /classinfo","plugin_classinfo");

RegisterHamHam_TakeDamage"player""FwdPlayerDamage");
RegisterHamHam_Spawn"id""plugin_classmenu");
register_event"DeathMsg" "fw_EvDeathMsg" "a" );

g_iMaxPlayers get_maxplayers( );


Indent. Also, either consistently use semicolons or avoid using them entirely.

PHP Code:
new menu menu_create("\rWarfighter Class Menu:""menu_handler");

menu_additem(menu"\wWar Machine""1"0);
menu_additem(menu"\wJet Fighter""2"0);
menu_additem(menu"\wStealth Bomber""3"0);
menu_additem(menu"\wScorpion Tank""4"0);
menu_additem(menu"\wApache Helicopter""5"0);
menu_additem(menu"\wRailgun Operator""6"0);
menu_additem(menu"\wSubmarine Seeker""7"0);

menu_setprop(menuMPROP_EXITMEXIT_ALL);

menu_display(idmenu0); 
This menu is static, i.e. it never changes depending on game state, so create it once in plugin_init() or a similar forward and store the handle globally.

PHP Code:
case 1:
{
    
// Print the message and destroy the menu
    
client_print(idprint_chat"[AMXX] You are now a War Machine! Type /classinfo!");
    
set_user_maxspeed(id,WMspeed);
    
set_user_health(id,200);
    
menu_destroy(menu);
}

case 
2:
{
    
client_print(idprint_chat"[AMXX] You are now a Jet Fighter! Type /classinfo!");
    
set_user_maxspeed(id,JFspeed);
    
set_user_health(id,175);
    
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha185)
    
menu_destroy(menu);

This code is extremely redundant. You can store the names and health settings globally in an array and then pass an index into that. If you don't understand what I mean, post and I'll give you an example.

PHP Code:
new key str_to_num(data); 
The item parameter is all you need.

PHP Code:
case 7:
{
    
client_print(idprint_chat"[AMXX] You are now a Submarine Seeker! Type /classinfo!");
    
set_user_maxspeed(id,SSspeed);
    
set_user_health(id,200);
    
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha130)
    
menu_destroy(menu);
}
}

// Kill the menu, and make a return.
menu_destroy(menu); 
You destroy the menu twice no matter what jump the code branches through. Remove all of the calls inside of the switch statement.

PHP Code:
if ( file_exists "Warfighter/classinfo.html" ) == )
show_motd(idmessageheader
else if ( 
file_exists "Warfighter/classinfo.html" ) == )
    
show_motd(id"Warfighter/classinfo.html""Warfighter classes"
You can use truth statements this way instead:

PHP Code:
if ( !file_exists "Warfighter/classinfo.html" ) ) 
This is far more readable and useful.

In addition, you check file_exists() twice. The compiler is stupid and will not optimize this out. Instead of else if, you can simply use else. The reason is that this is boolean logic; if we know that the statement "the file does not exist" is false, then we know that the statement "the file does exist" is true.

You also use the string "Warfighter/classinfo.html" three times, so it would be better cached.

PHP Code:
if ( iKiller && ( iKiller != iVictim ) ) 
You should check if iKiller is within the bounds of max players, like this:

PHP Code:
if ( <= iKiller <= g_iMaxPlayers && ( iKiller != iVictim ) ) 
Moving along...

PHP Code:
client_cmd(id,"spk warfighter/sounds/doublekill"); 
Does this work? You might have to add .wav at the end.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
 



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 17:40.


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