AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   array indexing, I am no good at it :/ (https://forums.alliedmods.net/showthread.php?t=127496)

HLM 05-21-2010 19:50

array indexing, I am no good at it :/
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

/********************************
Begin Defines
********************************/

#define PLUGIN "TFC Tech"
#define VERSION "0.1"
#define AUTHOR "Master"

#define TECH_LEVELS 6
#define TECHS_PER_LEVEL 4
#define MAX_TEAMS 4
#define VOTE_TIME 20        // seconds to vote

#define SENTRY_BASE_OFFSET_Z    21.2    // sentry is this many units up from base

#define TECH_SCOUT_SPEED    0,0
#define TECH_RAILGUN_BLAST    0,1
#define TECH_BLUEPIPE        0,2
#define TECH_SPY_INVIS        0,3

#define    TECH_AP_NAILS        1,0
#define TECH_SENTRY_PUSH    1,1
#define TECH_FLAG_TELEPORT    1,2
#define TECH_FAKE_FLAGS        1,3

#define TECH_STICKY_PIPES    2,0
#define TECH_CALTROP_INVIS    2,1
#define TECH_PYRO_ARMOR        2,2
#define TECH_WATER_BREATH    2,3

#define TECH_SPAWN_INVINC    3,0
#define TECH_DEATH_EXP        3,1
#define TECH_HW_FASTFIRE    3,2
#define TECH_ROCKET_DET        3,3

#define TECH_ADRENALINE        4,0
#define TECH_FLAG_THROW        4,1
#define TECH_NAIL_PUSH        4,2
#define TECH_FEIGN_REGEN    4,3

#define TECH_REGEN            5,0
#define TECH_RAGE            5,1
#define TECH_FLAG_RESTOCK    5,2
#define TECH_ANTIGRAV        5,3

#define FAST_SCOUT_SPEED    500
#define RAGE_QUAD_TIME        10
#define NAIL_PUSH_SPEED        800
#define GRAVITY_PROPORTION    0.1
#define AP_NAIL_BONUS        7
#define CALTROP_RENDERAMT    0
#define SHOCKWAVE_NAIL_COST 4
#define SHOCKWAVE_ENGY_ARMOR_COST    10
#define IMPLANT_DAMAGE        250
#define REGEN_RATE            2
#define FEIGN_REGEN_RATE    5
#define SPY_CLOAK_TIME        1
#define FLAG_TELEPORT_DELAY 1
#define FLAG_TELEPORT_H        50
#define FLAG_TELEPORT_A        100
#define PYRO_REGEN_RATE        5
#define PYRO_ARMOR_TYPE        0.8
#define SPAWN_INVINC_TIME    8
#define ANTIGRAV_DAMAGE        3

#define MAX_ENTITIES        1024
#define MAX_PLAYERS        32

#define NULL 0

/********************************
End Defines
********************************/


/********************************
Begin Global Defines
********************************/
new m_LaserBeamm_Shockwavem_Lightningm_XenoBeamm_Bubblem_Smokem_Fizz

new iNumberOfTeams;        // the number of teams in this map
new iHighestMapTeam;    // the highest team value for an info_player_teamspawn

new bool:bWasDead[MAX_PLAYERS];    // the old deadflag status, used to determine if the player just respawned

new Float:fLastHudUpdate[MAX_PLAYERS];    // timer for updating the text on player huds
new iLastTeam[MAX_PLAYERS];            // the last team the player was on when they respawned
new Float:fLastHealth[MAX_PLAYERS];        // health of the player at last Think
new Float:fLastArmor[MAX_PLAYERS];        // armor of the player at last Think
new Float:vecLastDamageOrigin[MAX_PLAYERS][3];    // the last origin from which a damage message was sent

new iNewEnts[MAX_ENTITIES];
new 
iNewEntCount;

new 
Float:fTechVoteTime[TECH_LEVELS];
new 
szTechName[TECH_LEVELS][TECHS_PER_LEVEL][256];        // the name of each tech
new szTechText[TECH_LEVELS][TECHS_PER_LEVEL][1024];    // the text that appears when you gain that tech

new bool:bInVote;            // are we currently in a vote?
new bool:bPlayerVoted[MAX_PLAYERS];    // which players have voted in the current vote
new Float:fVoteStartTime;    // the time the current vote started
new iCurrentTechLevel;    // what tech level are we voting on
new iVotesForTech[TECH_LEVELS][TECHS_PER_LEVEL][MAX_TEAMS];

new 
bool:bGotTech[TECH_LEVELS][TECHS_PER_LEVEL][MAX_TEAMS];

// variables used in techs
new Float:fLastMoveTime[MAX_PLAYERS];    // the time the player stopped moving
new Float:fLastSecondTick[MAX_PLAYERS];    // used to set a bool for things that should be done every second
new Float:vecDeathLocation[MAX_PLAYERS][3];
new 
Float:fHeldUseTime[MAX_PLAYERS];    // the time the player started holding the USE key

new bool:bFlagWasHeld[MAX_ENTITIES];        // was the flag with this index being held last frame?
new iFlagLastTeam[MAX_ENTITIES];        // the last team to hold this flag

//edict_t *pSentryPair[MAX_ENTITIES];        // used to pair up sentries and sentry bases
new pSentryPair[MAX_ENTITIES];

/********************************
End Global Defines
********************************/

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
}


public 
plugin_precache()
{
    
// store the indices of spries, so we can use them with messages
    
m_LaserBeam precache_model("sprites/laserbeam.spr");
    
m_Shockwave precache_model("sprites/shockwave.spr");
    
m_Lightning precache_model("sprites/lgtning.spr");
    
m_XenoBeam precache_model("sprites/xenobeam.spr");
    
m_Bubble precache_model("sprites/bubble.spr");
    
m_Smoke precache_model("sprites/smoke.spr");
    
m_Fizz precache_model("sprites/bhit.spr");
    
    
// don't bother storing indices of models and sounds
    //precache_model("models/presentlg.mdl");
    //precache_model("models/presentsm.mdl");
    
precache_model("models/invis.mdl");
    
precache_model("models/rpgrocket.mdl");
    
precache_model("models/can.mdl");
    
    
precache_sound("buttons/blip1.wav");
    
precache_sound("items/medshot4.wav");
    
precache_sound("items/gunpickup2.wav");
    
precache_sound("items/inv1.wav");
    
precache_sound("player/heartbeat1.wav");
    
precache_sound("items/damage.wav");
    
precache_sound("items/airtank1.wav");
    
precache_sound("items/suitchargeok1.wav");
    
precache_sound("weapons/grenade_hit1.wav");
    
precache_sound("weapons/grenade_hit2.wav");
    
precache_sound("weapons/grenade_hit3.wav");
    
precache_sound("weapons/mine_charge.wav");
    
precache_sound("debris/beamstart7.wav");
    
//precache_sound("vox/no.wav");
    
precache_sound("turret/tu_spinup.wav");
    
    
Initialize();    // reset variables for new map    
}

stock Initialize()
{
    new 
ij;
    
    for(
0MAX_PLAYERSi++)
    {
        
InitializePlayer(i+1);
    }
    
    
iNewEntCount 0;
    for(
0MAX_ENTITIESi++)
    {
        
iNewEnts[i] = 0;
        
bFlagWasHeld[i] = false;
        
iFlagLastTeam[i] = 0;
        
pSentryPair[i] = NULL;
    }
    
    
iNumberOfTeams 4;    // 4 is default in case of no info_tfdetect entity (hldm maps)
    
iHighestMapTeam 0;    // incremented whenver an info_player_teamspawn with higher team is found
    
    
fTechVoteTime[0] = 2.0;
    
fTechVoteTime[1] = 5.0;
    
fTechVoteTime[2] = 10.0;
    
fTechVoteTime[3] = 15.0;
    
fTechVoteTime[4] = 20.0;
    
fTechVoteTime[5] = 25.0;
    
    
    
/*
    fTechVoteTime[0] = .2;
    fTechVoteTime[1] = .5;
    fTechVoteTime[2] = .10;
    fTechVoteTime[3] = .15;
    fTechVoteTime[4] = .20;
    fTechVoteTime[5] = .25;
    */
    
    
bInVote false;
    
fVoteStartTime 0.0;    // the time the current vote started
    
    
iCurrentTechLevel 0;    // what tech level are we voting on
    
    
for(0TECH_LEVELSi++)
    {
        for(
0TECHS_PER_LEVELj++)
        {
            
copy(szTechName[i][j], 255"(undefined tech)");
            
copy(szTechText[i][j], 1023"(undefined tech text)");
            
            
iVotesForTech[i][j][0] = 0;
            
iVotesForTech[i][j][1] = 0;
            
iVotesForTech[i][j][2] = 0;
            
iVotesForTech[i][j][3] = 0;
            
            
bGotTech[i][j][0] = false;
            
bGotTech[i][j][1] = false;
            
bGotTech[i][j][2] = false;
            
bGotTech[i][j][3] = false;
        }
    }
    
    
copy(szTechName[0][0], 255"Fast Scouts");
    
copy(szTechName[0][1], 255"Railgun Shockwave");
    
copy(szTechName[0][2], 255"Stronger Blue Pipes");
    
copy(szTechName[0][3], 255"Spy Cloaking");
    
    
copy(szTechText[0][0], 1023"Scouts on your team are now faster.");
    
copy(szTechText[0][1], 1023"Your railguns now cause a shockwave on impact.");
    
copy(szTechText[0][2], 1023"Your blue pipebombs now do more damage when they explode.");
    
copy(szTechText[0][3], 1023"Spies on your team can become invisible by standing still.");
    
    
copy(szTechName[1][0], 255"Armor Piercing Nails");
    
copy(szTechName[1][1], 255"Movable Sentry Guns");
    
copy(szTechName[1][2], 255"Defensive Flag Teleport");
    
copy(szTechName[1][3], 255"Decoy Flags");
    
    
copy(szTechText[1][0], 1023"Your nailguns now do extra damage which bypasses armor.");
    
copy(szTechText[1][1], 1023"Engineers on your team can now push sentries with the USE key.");
    
copy(szTechText[1][2], 1023"Soldiers with enough health can hold USE to teleport to their flag on some maps.");
    
copy(szTechText[1][3], 1023"When the enemy drops the flag, it will throw out several decoys.");
    
    
copy(szTechName[2][0], 1023"Sticky Pipebombs");
    
copy(szTechName[2][1], 1023"Invisible Caltrops");
    
copy(szTechName[2][2], 1023"Improved Pyro Armor");
    
copy(szTechName[2][3], 1023"Underwater Breathing");
    
    
copy(szTechText[2][0], 1023"Your team's pipebombs can now be stuck to walls and ceilings.");
    
copy(szTechText[2][1], 1023"Your caltrops will blend in to whatever surface they land on.");
    
copy(szTechText[2][2], 1023"Pyros on your team now have drastically improved armor.");
    
copy(szTechText[2][3], 1023"Players on your team can now breathe water.");
    
    
copy(szTechName[3][0], 255"Respawn Immunity");
    
copy(szTechName[3][1], 255"Explosive Implants");
    
copy(szTechName[3][2], 255"Fast Firing HWGuys");
    
copy(szTechName[3][3], 255"Dettable Rockets");
    
    
copy(szTechText[3][0], 1023"Medics, scout, spies, pyros and demomen are invincible for a few seconds after spawning.");
    
copy(szTechText[3][1], 1023"Scouts, medics, demomen and pyros on your team now deal damage after death.");
    
copy(szTechText[3][2], 1023"Heavy Weapon Guys on your team can now move normally while firing.");
    
copy(szTechText[3][3], 1023"Soldiers can press USE to detonate their rockets early.");
    
    
copy(szTechName[4][0], 255"Adrenaline Speed Burst");
    
copy(szTechName[4][1], 255"Improved Flag Throw");
    
copy(szTechName[4][2], 255"Knockback Supernailgun");
    
copy(szTechName[4][3], 255"Feign Regeneration");
    
    
copy(szTechText[4][0], 1023"After losing enough health, players on your team gain a speed boost.");
    
copy(szTechText[4][1], 1023"Players on your team can throw the flag a lot further.");
    
copy(szTechText[4][2], 1023"The supernailguns of your medics now cause knockback on impact.");
    
copy(szTechText[4][3], 1023"While feigned, your spies will regenerate health and armor.");
    
    
copy(szTechName[5][0], 255"Regeneration");
    
copy(szTechName[5][1], 255"Soldier Quad Rage");
    
copy(szTechName[5][2], 255"Flag Touch Restock");
    
copy(szTechName[5][3], 255"Antigravity");
    
    
copy(szTechText[5][0], 1023"Players on your team will regenerate health.");
    
copy(szTechText[5][1], 1023"For a short time after killing someone with a rocket, your soldiers will deal quad damage.");
    
copy(szTechText[5][2], 1023"Medics and scouts will regain some health, armor and concs when they take the flag.");
    
copy(szTechText[5][3], 1023"Unless you're a soldier or engineer, you can press the USE key to toggle low gravity.");
}

stock InitializePlayer(index)
{
    
index -= 1;                    // assume ent index is passed
    
    
bWasDead[index] = true;        // assume all players are dead before they spawn for the first time
    
fLastHudUpdate[index] = 0.0;
    
iLastTeam[index] = 0;
    
vecDeathLocation[index][3] = {
        
0.0,
        
0.0,
        -
4096.0
        
}// way down below the map so that death explosion is invisible
        
bPlayerVoted[index] = false;
        
fLastMoveTime[index] = 0.0;
        
fLastSecondTick[index] = 0.0;
        
fHeldUseTime[index] = 0.0;
        
        
fLastHealth[index] = 0.0;
        
fLastArmor[index] = 0.0;
        
vecLastDamageOrigin[index][3] = {
            
0.0,
            
0.0,
            
0.0
        
}
    } 

vecDeathLocation[index][3] = {
0.0,
0.0,
-4096.0
}// way down below the map so that death explosion is invisible

vecLastDamageOrigin[index][3] = {
0.0,
0.0,
0.0
}

although, im assuming it has something to do with the way im getting the user index?... but if this is going to be like this, I could just do all of this on client_connect..

I guess this is a "thoughts thread" then, unless someone can help me, since ill probably still get this problem, lol

Bugsy 05-21-2010 20:06

Re: array indexing, I am no good at it :/
 
Sorry, but what exactly is your question\issue? Also, you do not need to define those functions as stocks since you are definitely using them.

Exolent[jNr] 05-21-2010 20:11

Re: array indexing, I am no good at it :/
 
Code:
new Float:vecVector[ 3 ]; // option 1 vecVector = Float:{ 1.0, 2.0, 3.0 }; // option 2 vecVector[ 0 ] = 1.0; vecVector[ 1 ] = 2.0; vecVector[ 2 ] = 3.0;

HLM 05-21-2010 20:25

Re: array indexing, I am no good at it :/
 
if I dont define them as stocks, pawn studio will act as if the code doesnt exist and mess up my indentation, exolent, thanks for the assistance, bugsy, if you know an alternative way to keep the indenting, im all ears, I do have notepad++, but I cant get the syntax highlighters installed (im a rookie with n++ and I dont bother with it too much, lol)

once again, thanks

Bugsy 05-21-2010 20:32

Re: array indexing, I am no good at it :/
 
Quote:

Originally Posted by HLM (Post 1187326)
if I dont define them as stocks, pawn studio will act as if the code doesnt exist and mess up my indentation, exolent, thanks for the assistance, bugsy, if you know an alternative way to keep the indenting, im all ears, I do have notepad++, but I cant get the syntax highlighters installed (im a rookie with n++ and I dont bother with it too much, lol)

once again, thanks

You should not let indentation warnings be the reason for using 'stock' or any other piece of code. Use tabs to indent and be consistent with it and you shouldn't have any problems. I personally use AMXX-Studio, its lightweight and easy to use.

fysiks 05-21-2010 23:38

Re: array indexing, I am no good at it :/
 
Quote:

Originally Posted by HLM (Post 1187326)
I do have notepad++, but I cant get the syntax highlighters installed (im a rookie with n++ and I dont bother with it too much, lol)

You can just set the language to C++.

issen1 05-22-2010 06:59

Re: array indexing, I am no good at it :/
 
Also:
Quote:

When you open a file in notepad++ it will attempt to load syntax highlighting for the contents based on file extension.

If you use custom extension for one of the existing languages you can add the custom extension in Settings -> Styler Configurator. Select language and add the extension in "User extension" edit box. To add multiple extensions separate them using space.

You can also change syntax highlighting style by selecting a different language from language menu. (source)


All times are GMT -4. The time now is 03:55.

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