Aller au contenu

Photo

Giving XP to all players? + Making sure the player is in the right area?


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
BuilderOfLegend

BuilderOfLegend
  • Members
  • 18 messages
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!
:)

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


#2
ehye_khandee

ehye_khandee
  • Members
  • 855 messages
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

#3
BuilderOfLegend

BuilderOfLegend
  • Members
  • 18 messages
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 .


#4
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Just need another "=".

if (oArea == oAnAr)

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


#5
BuilderOfLegend

BuilderOfLegend
  • Members
  • 18 messages
Thanks!