Raised This Month: $ Target: $400
 0% 

Proofreading


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OneMoreLevel
Senior Member
Join Date: Aug 2009
Location: Look behind you... Very
Old 10-19-2009 , 19:55   Proofreading
Reply With Quote #1

I was wondering if someone would like to proofread this for me:
http://www.ampaste.net/m29e3dd6f

I've already ran through it and compiled, I haven't seen any problems, but I was wondering if someone with a bit more scripting experience would like to try it.

Also, would anyone mind doing a quick bug test on their servers, I don't have one and it would be really appreciated.

P.S. It's not like I'm lazy or anything, but I use Cstrikes "new game" option and It wont let any one on there besides me.
__________________
60/100 60%
[||||||||||||||||||||]
Project: Warfighter mod
Blog:
http://sites.google.com/site/dailymultitasker/
PHP Code:
   if ( i_help_you "Yes" ) == )
    
set_user_karma(onemorelevel,add,+1
OneMoreLevel is offline
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
OneMoreLevel
Senior Member
Join Date: Aug 2009
Location: Look behind you... Very
Old 10-20-2009 , 12:28   Re: Proofreading
Reply With Quote #3

First of thanks alot, It must have tooken quite awhile to do that.

About indenting, when I press Ctrl-I in the compiler, it just brings the code to look like that, and when I indent by myself, it gives me some warnings.

Quote:
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.
Please do, Im still quite a newb at this.

Quote:
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.
Im also Quite confused with this one, I know what you mean by creating it in plugin_init, but I dont understand the storing it globally part.

Quote:
The item parameter is all you need.
And that, so just a few I need help with, everything else i can do

Again, Thanks alot
__________________
60/100 60%
[||||||||||||||||||||]
Project: Warfighter mod
Blog:
http://sites.google.com/site/dailymultitasker/
PHP Code:
   if ( i_help_you "Yes" ) == )
    
set_user_karma(onemorelevel,add,+1
OneMoreLevel is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-20-2009 , 12:44   Re: Proofreading
Reply With Quote #4

Quote:
Originally Posted by OneMoreLevel View Post
First of thanks alot, It must have tooken quite awhile to do that.

About indenting, when I press Ctrl-I in the compiler, it just brings the code to look like that, and when I indent by myself, it gives me some warnings.
Use tab instead of spaces.

Quote:
Originally Posted by OneMoreLevel View Post
Please do, Im still quite a newb at this.
PHP Code:
enum MODES
{
    
WM 0,
    
JF,
    
SB,
    
ST,
    
AH,
    
RO,
    
SS
}

new 
Float:gSpeeds[_:MODES] =
{
    
300.0,
    
400.0,
    
350.0,
    
250.0,
    
300.0,
    
325.0,
    
275.0
}

new 
gHealths[_:MODES] =
{
    
200,
    
175,
    
175,
    
255,
    
150,
    
175,
    
200
}

new 
gNames[_:MODES][] =
{
    
"War Machine",
    
"Jet Fighter",
    
"Stealth Bomber",
    
"Scorpion Tank",
    
"Apache Helicopter",
    
"Railgun Operator",
    
"Submarine Seeker"
}

// ...

    
client_printidprint_chat"[AMX] You are now a %s. Type /classinfo for information."gNames[item] )
    
set_user_maxspeedidgSpeeds[item] )
    
set_user_healthidgHealths[item] )

// ...
    
    
switch ( item )
    {
        case 
JF :
            
set_user_renderingidkRenderFxGlowShell000kRenderTransAlpha185 )
        case 
SB :
        {
            
set_user_renderingidkRenderFxGlowShell000kRenderTransAlpha65 )
            
cs_set_user_bpammoidCSW_HEGRENADE)
        }
        case 
SS :
            
set_user_renderingidkRenderFxGlowShell000kRenderTransAlpha130 )
    } 
That's a generalized solution to what you were asking.

Quote:
Originally Posted by OneMoreLevel View Post
Im also Quite confused with this one, I know what you mean by creating it in plugin_init, but I dont understand the storing it globally part.
PHP Code:
new gMenu

public plugin_init()
    
gMenu menu_create"whatever""who cares" )

// ...
    
    
menu_displayidgMenu )

// ...

public plugin_end()
    
menu_destroygMenu 
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-20-2009 , 12:45   Re: Proofreading
Reply With Quote #5

Also, I just noticed your cs_set_user_bpammo() call. I don't think it will allow you to add more than 1 HE grenade to the person's backpack. You'll have to catch when it's thrown and then give the user another one.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-20-2009 , 13:18   Re: Proofreading
Reply With Quote #6

Quote:
Originally Posted by Hawk552 View Post
Also, I just noticed your cs_set_user_bpammo() call. I don't think it will allow you to add more than 1 HE grenade to the person's backpack. You'll have to catch when it's thrown and then give the user another one.
You can set as many HE as you want

About avoiding the "new" operator, i don't think you can for arrays.
__________________
- 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 17:40.


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