Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Help with an array.
Help with an array. [message #390692] Mon, 15 June 2009 09:32 Go to next message
Xpert is currently offline  Xpert
Messages: 1588
Registered: December 2005
Location: New York City
Karma: 0
General (1 Star)
Okay, so basically, I'm trying to get an array going to count the players that damage a certain vehicle(s). I was getting help from someone with this and so far no luck. Maybe someone can find what we're doing wrong?


int damageObject[127];
void reb_vehicle::Created(GameObject *obj) {
        vehstartmaxhealth = Commands->Get_Max_Health(obj);
        vehstartmaxarmor = Commands->Get_Max_Shield_Strength(obj);
        Commands->Start_Timer(obj, this, 1.5f, 1);
        this->isUpgraded = false;
        for (int i=0; i < 128; i++)
        {
                damageObject[i] = 0;
        }
}
 
void reb_vehicle::Damaged(GameObject *obj, GameObject *damager, float damage) {
        if (damage < 0) {           
                if (Commands->Is_A_Star(damager) && Commands->Get_Player_Type(damager) == Commands->Get_Player_Type(obj)) {
                        RepUpdate(Get_Player_ID(damager), (int)((damage - damage) - damage)/2);
                }
        }
		int objId = Get_Player_ID(damager);
        damageObject[objId] = objId;
}
 
void reb_vehicle::Killed(GameObject *obj, GameObject *shooter) {
        if (Commands->Is_A_Star(shooter) && Commands->Get_Player_Type(shooter) != Commands->Get_Player_Type(obj)) {
                for (int i=0; i < 1;i++)
                {
                        GameObject *mainobj = Get_GameObj(damageObject[i]);
                        VetUpdate(damageObject[i], (int)GetPoints(Commands->Get_Preset_Name(obj)), (int)Commands->Get_Points(mainobj));
                        Display_Int_Player(mainobj,GetPoints(Commands->Get_Preset_Name(obj)),"Veteran points gained: %d  "),GetPoints(Commands->Get_Preset_Name(obj));
                }
        }
}


It crashes when the damaged vehicle gets killed/destroyed.

And the structure for VetUpdate is
VetUpdate(int ID, int number, int score)



http://i32.photobucket.com/albums/d42/XpertMaverick/xpertyankee.jpg

Creator of NetGuard, an IRC network regulator.
Developer of the CloudyServ 0.982-X project.
Developer of the CloudyServ Ren-X bot.

Part time streamer - https://twitch.tv/gg_wonder
Re: Help with an array. [message #390695 is a reply to message #390692] Mon, 15 June 2009 09:54 Go to previous messageGo to next message
Xpert is currently offline  Xpert
Messages: 1588
Registered: December 2005
Location: New York City
Karma: 0
General (1 Star)
I put this topic in the wrong section, can someone move it to Mod Forum plz?

http://i32.photobucket.com/albums/d42/XpertMaverick/xpertyankee.jpg

Creator of NetGuard, an IRC network regulator.
Developer of the CloudyServ 0.982-X project.
Developer of the CloudyServ Ren-X bot.

Part time streamer - https://twitch.tv/gg_wonder
Re: Help with an array. [message #390697 is a reply to message #390692] Mon, 15 June 2009 10:03 Go to previous messageGo to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
2 things I can see here:

First, you need to declare 'damageObject' inside of the script if you want the object that the script is attached to to track player attacking it.

Also:
GameObject *mainobj = Get_GameObj(damageObject[i]);
                        VetUpdate(damageObject[i], (int)GetPoints(Commands->Get_Preset_Name(obj)), (int)Commands->Get_Points(mainobj));



You need to check mainobj before you use it. If Get_GameObj returns 0, it will crash.

EDIT: third, VetUpdate parameter 1 isn't a GameObj *, it is an int. Probably player ID. Use VetUpdate(Get_PlayerID(damageObject[i]), ...

[Updated on: Mon, 15 June 2009 10:05]

Report message to a moderator

Re: Help with an array. [message #390703 is a reply to message #390692] Mon, 15 June 2009 10:44 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
Who was helping you with this? Also, grab me on MSN if you have not got this sorted, I think i can help.


Re: Help with an array. [message #390710 is a reply to message #390692] Mon, 15 June 2009 13:06 Go to previous messageGo to next message
raven
Messages: 595
Registered: January 2007
Location: Toronto, Ontario
Karma: 0
Colonel
After yelling at Xpert a lot, I managed to help him fix it properly Razz Thanks jnz.. that helped Thumbs Up

-Jelly Administrator
-Exodus Administrator
Re: Help with an array. [message #390711 is a reply to message #390692] Mon, 15 June 2009 13:07 Go to previous message
Xpert is currently offline  Xpert
Messages: 1588
Registered: December 2005
Location: New York City
Karma: 0
General (1 Star)
Even though you were a bitch :\

http://i32.photobucket.com/albums/d42/XpertMaverick/xpertyankee.jpg

Creator of NetGuard, an IRC network regulator.
Developer of the CloudyServ 0.982-X project.
Developer of the CloudyServ Ren-X bot.

Part time streamer - https://twitch.tv/gg_wonder
Previous Topic: First Map in 3D Studio Max
Next Topic: How would i go about making a hud.ini
Goto Forum:
  


Current Time: Sat Dec 21 02:22:03 MST 2024

Total time taken to generate the page: 0.00799 seconds