Hey everyone,
I need to make a simple mod to my resting script. I am using this one from the vault by Sorceress Ashura:
void main()
{
object oPC = GetLastPCRested();
if (GetLocalInt(oPC, "PlayerRestVariable")== 1)
{
//Do nothing rest as normal.
}
else
{
if (GetItemPossessedBy(oPC, "ROR_Bedroll")!= OBJECT_INVALID)
{
//Do nothing, rest as usual.
}
else
{
// Clear Actions, canceling rest..
SendMessageToPC(oPC, "You need a bedroll to rest, find a campfire or Inn.");
AssignCommand(oPC, ClearAllActions());
}
}
}
What I want to change is the second condition. I dont want it to check for an item in the inventory I want to check to see if the PC is close to a fire as created by the PC tools. The tag for the Fire that is created is HSS_CAMPFIRE_01
I just dont seem to have the scripting skills to figure out how to do this.
Help with Resting Script
Débuté par
niapet
, févr. 13 2011 03:14
#1
Posté 13 février 2011 - 03:14
#2
Guest_Chaos Wielder_*
Posté 13 février 2011 - 04:15
Guest_Chaos Wielder_*
Use this as the new if condition:
if(GetDistanceBetween(oPC, GetNearestObjectByTag("HSS_CAMPFIRE_01", oPC))<=5.0f)
Now, the final number at the end can be adjusted by how much distance you want between the player the fire. 2.5f for closer...you get the idea.
if(GetDistanceBetween(oPC, GetNearestObjectByTag("HSS_CAMPFIRE_01", oPC))<=5.0f)
Now, the final number at the end can be adjusted by how much distance you want between the player the fire. 2.5f for closer...you get the idea.
#3
Posté 15 février 2011 - 03:35
Thanks for the help, quick question can i just add in a requirement for the tent being close as well like this:
if(GetDistanceBetween(oPC, GetNearestObjectByTag("HSS_CAMPFIRE_01", oPC))<=5.0f) && if(GetDistanceBetween(oPC, GetNearestObjectByTag("HS_TENT_01", oPC))<=5.0f)
if(GetDistanceBetween(oPC, GetNearestObjectByTag("HSS_CAMPFIRE_01", oPC))<=5.0f) && if(GetDistanceBetween(oPC, GetNearestObjectByTag("HS_TENT_01", oPC))<=5.0f)
#4
Posté 15 février 2011 - 04:17
To check multiple conditions the syntax is
if ( this && that )
So you do not need the second "if" and you need an additional set of parantheses around everything after the first "if".
Like so:
if ( (GetDistanceBetween(oPC, GetNearestObjectByTag("HSS_CAMPFIRE_01", oPC)) <= 5.0f )
&& (GetDistanceBetween(oPC, GetNearestObjectByTag("HS_TENT_01", oPC)) <= 5.0f ) )
{
// your code here
}
Regards
if ( this && that )
So you do not need the second "if" and you need an additional set of parantheses around everything after the first "if".
Like so:
if ( (GetDistanceBetween(oPC, GetNearestObjectByTag("HSS_CAMPFIRE_01", oPC)) <= 5.0f )
&& (GetDistanceBetween(oPC, GetNearestObjectByTag("HS_TENT_01", oPC)) <= 5.0f ) )
{
// your code here
}
Regards
Modifié par Kaldor Silverwand, 15 février 2011 - 03:49 .
#5
Posté 20 février 2011 - 10:22
What Kaldor said, although, for the record, you can nest if statements. So you can put:
if(this)
{
if(this also)
{
//Your code here
}
}
It's normally better to use if(this && that), though, unless your condition list is long and messy (e.g. using a big mess of ANDs - && - and ORs - || - or something).
if(this)
{
if(this also)
{
//Your code here
}
}
It's normally better to use if(this && that), though, unless your condition list is long and messy (e.g. using a big mess of ANDs - && - and ORs - || - or something).
Modifié par The Fred, 20 février 2011 - 10:31 .





Retour en haut






