Author Topic: Giving XP to all players? + Making sure the player is in the right area?  (Read 279 times)

Legacy_BuilderOfLegend

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0


               I am designing an Arena, in which the player must try to survive as long as they can against a sea of enemies. I have set it up so when they chose to respawn they wont lose XP and have set it up also so that when they Level Up they get aditional bonuses, so that's almost all the scripting I need covered EXCEPT this.

My plan is to give them a steady stream of XP (I have currently got it at 1 per heartbeat, but that may be to fast, haven't tested it yet), but I can't seem to find a function that lets you get ALL players. (I can find stuff like "GetFirstPC" and so such, but really I would rather not have to guess how many PCs are on and would prefer to just get a "GetAllPC" or better, a function that gives to all PCs).

Any help would be great!
'<img'>
               
               

               


                     Modifié par BuilderOfLegend, 05 juillet 2012 - 08:26 .
                     
                  


            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
Giving XP to all players? + Making sure the player is in the right area?
« Reply #1 on: July 04, 2012, 09:55:25 pm »


               GetFirstPC()

is meant to be used in a loop with

GetNextPC()

you can do something like this...


object oTarget = GetFirstPC();
while(GetIsObjectValid(oTarget))
{
// do what needs doing here
oTarget = GetNextPC();
}

Hope this helps. Beware using heartbeats for too much, they induce lag like there's no tomorrow.

Be well. Game on.
GM_ODA
               
               

               
            

Legacy_BuilderOfLegend

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Giving XP to all players? + Making sure the player is in the right area?
« Reply #2 on: July 05, 2012, 08:53:54 am »


               Thanx!

Edit: Works all fine, excpet it seems to still give XP to players who are NOT in
the correct area. I am trying to find a way around this, and have found
"GetArea", but can't seem to find what it returns as (so what to check
on the "if" statement). My current script is looking like this:

//Thanks to ehye_khandee for the main body of this script!
void main()
{
object oAnch = GetObjectByTag("port_control");
object oTarget = GetFirstPC();
object oArea = GetArea(oTarget);
object oAnAr = GetArea(oAnch);
while(GetIsObjectValid(oTarget))
{
//Reward XP Here!
if (oArea = oAnAr)
{
GiveXPToCreature(oTarget, 1);
}
oTarget = GetNextPC();
}
}

This comes up with the error:

05/07/2012 09:23:43: Error. 'sc_give_xp' did not compile.
sc_give_xp.nss(11): ERROR: NON INTEGER EXPRESSION WHERE INTEGER REQUIRED

Edit: I forgot to mention earlier. "port_control" is the tag of a Flaming Satue in the Arena area that I am trying to use to compare the player's area to the area it is in, to see if the player needs the XP.

Any help with sorting this out would be great!

BuilderOfLegend

PS: Your script worked great, apart from this problem, which is probably due to my scripting. The original script is perfect but for the problem it works on Anyone in Any area.
               
               

               


                     Modifié par BuilderOfLegend, 05 juillet 2012 - 08:52 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Giving XP to all players? + Making sure the player is in the right area?
« Reply #3 on: July 05, 2012, 10:40:07 am »


               Just need another "=".

if (oArea == oAnAr)
               
               

               


                     Modifié par GhostOfGod, 05 juillet 2012 - 09:40 .
                     
                  


            

Legacy_BuilderOfLegend

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Giving XP to all players? + Making sure the player is in the right area?
« Reply #4 on: July 05, 2012, 11:00:58 am »


               Thanks!