Resource gathering script
#1
Posté 28 septembre 2010 - 08:26
oUser // Pc wich is using placable ( tree, ore vein, etc.)
oTool // Tool wich oUser has in inventory, and would be different regarding the oSorce(axe, pickaxe, etc.)
oSorce // The source that oPc is using (by left click so this script should be on click)
nSkill // I would either use SURVIAVAl or new skill for this
nSkill level //level of selected skill
oMaterial // Material that oUser gets
nSTR // STR level of oUser
nGive // quantitiy od oMaterial to be given to oUser
And now the script checks if required level is matched, if required tool is matched and then makes animation and sound, gives oMaterial to oUser depending on his sternght( if STR<10 give 0, 10-15 give 1, 16-20 give 2 and STR>20 give 3) and then DOESN'T give anything for next 5 minutes. And some messages like "oUser got n Material" and "oSource is empty".
Please help.
#2
Posté 28 septembre 2010 - 09:17
#3
Posté 28 septembre 2010 - 03:43
#4
Posté 28 septembre 2010 - 07:19
#5
Posté 28 septembre 2010 - 08:04
Modifié par rjshae, 28 septembre 2010 - 09:47 .
#6
Posté 28 septembre 2010 - 09:55
Also, posting what script you have so far will help us help you.
Modifié par _Knightmare_, 28 septembre 2010 - 09:55 .
#8
Posté 29 septembre 2010 - 06:26
#9
Posté 29 septembre 2010 - 09:01
Regards
#10
Posté 30 septembre 2010 - 06:41
#11
Posté 02 octobre 2010 - 06:30
(22): ERROR: NO RIGHT BRACKET ON EXPRESSION
It's the row with "if" condition, and if I delete whole row, it compiles succesfully.
That is weird because i have equal number of left and right brackets:alien:.
So does anyone know what the problem is?
// Placeable OnUsed Gain some resources
// Created by: DragonDario
// Created on: 01.10.2010.
/*
Required: Static=FALSE, Usable=TRUE, CurrentHP>0, attach script to the OnUsed event
Suggested: Plot=TRUE, DefaultActionPreference="Use"
*/
//
#include "ginc_debug"
void main(string sTool, string sOre)
{
object oUser = GetLastUsedBy();
object oPlaceable = OBJECT_SELF;
int nStack = GetAbilityScore(oUser, ABILITY_STRENGTH, FALSE) - GetHardness(oPlaceable);
location lItem = GetLocation(oPlaceable);
float fDelay = 2.5;
float fDelayAction= 300.0;
string sUsed;
PrettyDebug(GetName(oPlaceable) + "'s was used by " + GetName(oUser));
if((GetItemPossessedBy(oUser, sOre)) ˛˛ (nStack > 0) ˛˛ (GetLocalInt(oUser, sUsed)))
{
CreateItemOnObject(sOre, oUser, nStack, "", TRUE);
SetLocalInt(oUser, sUsed, 1);
DelayCommand(fDelayAction, DeleteLocalInt(oUser, sUsed));
}
else
{
PrettyError("You don't have the right tool or have to low strenght.", fDelay, 16711680);
}
}
#12
Posté 02 octobre 2010 - 11:58
DragonDario wrote...
Here is the script now, but unfortunally the compiler says:
(22): ERROR: NO RIGHT BRACKET ON EXPRESSION
It's the row with "if" condition, and if I delete whole row, it compiles succesfully.
That is weird because i have equal number of left and right brackets:alien:.
So does anyone know what the problem is?
You have 5 opening/right brackets but 6 closing/left brackets. Delete one of the left brackets.
Also, I see where you declared string sUsed; and later used that as a parameter in a couple functions, but don't see where you assigned sUsed a value.
Modifié par _Knightmare_, 02 octobre 2010 - 12:03 .
#13
Posté 02 octobre 2010 - 11:55
void main()
You will need to define sTool and sOre within the main function. You can get sTool by getting the tag of the object returned by the GetItemInSlot function. For sOre I would get that by checking a local variable on the placeable.
Off hand, I don't see the bracket problem, but usually they aren't hard to figure out. Just comment out different sections of the script and compile until you figure out which section introduces the error. For such a short script it should only take a minute to figure out.
Regards
Modifié par Kaldor Silverwand, 02 octobre 2010 - 11:56 .
#14
Posté 03 octobre 2010 - 07:08
I have made some improvments on script but still get the same error on same field:
// Placeable OnUsed Gain some resources
// Created by: DragonDario
// Created on: 01.10.2010.
/*
Required: Static=FALSE, Usable=TRUE, CurrentHP>0, attach script to the OnUsed event
Suggested: Plot=TRUE, DefaultActionPreference="Use"
*/
//
#include "ginc_debug"
void main(string sTool, string sOre)
{
object oUser = GetLastUsedBy();
object oPlaceable = OBJECT_SELF;
int nStack = GetAbilityScore(oUser, ABILITY_STRENGTH, FALSE) - GetHardness(oPlaceable);
location lItem = GetLocation(oPlaceable);
float fDelay = 2.5;
float fDelayAction= 300.0;
string sUsed;
PrettyDebug(GetName(oPlaceable) + "'s was used by " + GetName(oUser));
if((GetItemPossessedBy(oUser, sOre)) ˛˛ (nStack > 0) ˛˛ (GetLocalInt(oUser, sUsed) != 1))
{
CreateItemOnObject(sOre, oUser, nStack, "", TRUE);
SetLocalInt(oUser, sUsed, 1);
DelayCommand(fDelayAction, SetLocalInt(oUser, sUsed, 0));
}
else
{
PrettyError("You don't have the right tool or have to low strenght.", fDelay, 16711680);
}
}
#15
Posté 03 octobre 2010 - 07:23
Modifié par DragonDario, 03 octobre 2010 - 11:19 .
#16
Posté 09 octobre 2010 - 05:38
// Placeable OnUsed Gain some resources
// Created by: DragonDario
// Created on: 01.10.2010.
/*
Required: Static=FALSE, Usable=TRUE, CurrentHP>0, attach script to the OnUsed event
Suggested: Plot=TRUE, DefaultActionPreference="Use"
*/
//
#include "ginc_debug"
void main(string sTool, string sRaw, string sSound, string nUsed, string nXP)
{
object oUser = GetLastUsedBy();
object oPlaceable = OBJECT_SELF;
int nStack = GetAbilityScore(oUser, ABILITY_STRENGTH, FALSE) - GetHardness(oPlaceable);
location lItem = GetLocation(oPlaceable);
float fDelay = 2.5;
float fDelayAction= 300.0;
PrettyDebug(GetName(oPlaceable) + "'s was used by " + GetName(oUser));
if(GetItemInSlot(INVENTORY_SLOT_CWEAPON_B, oUser) == GetItemPossessedBy(oUser, GetLocalString(oPlaceable, sTool)))
{
if(nStack > 0)
{
if(GetLocalInt(oPlaceable, nUsed) != 1)
{
ActionPlayAnimation(ANIMATION_LOOPING_CRAFT01, 1.50, 5.00);
PlaySound(sSound, FALSE);
GiveXPToCreature(oUser, GetLocalInt(oPlaceable, nXP));
CreateItemOnObject(GetLocalString(oPlaceable, sRaw), oUser, nStack, "", TRUE);
SetLocalInt(oPlaceable, nUsed, 1);
DelayCommand(fDelayAction, SetLocalInt(oPlaceable, nUsed, 0));
}
else
{
PrettyError("You have already used this resource out.", fDelay, 16711680);
}
}
else
{
PrettyError("You have too low strenght.", fDelay, 16711680);
}
}
else
{
PrettyError("You don't have the right tool.", fDelay, 16711680);
}
}
And script compiles successfully but doesn't work at all so if any1 got any suggestion, idea or anything else please let me know.
#17
Posté 09 octobre 2010 - 05:47
The above is your biggest problem. Scripts of this sort, where there is paramters listed in the ( ) of the void main line, only work when fired from a conversation.
If you are looking to do it so when a player somehow interacts with a placeable or whatever, you will need to remove everything inside those ( ) and set their values within the script itself.
#18
Posté 10 octobre 2010 - 07:48
// Placeable OnUsed Gain some resources
// Created by: DragonDario
// Created on: 01.10.2010.
/*
Required: Static=FALSE, Usable=TRUE, CurrentHP>0, attach script to the OnUsed event
Suggested: Plot=TRUE, DefaultActionPreference="Use"
*/
//
#include "ginc_debug"
void main()
{
object oUser = GetLastUsedBy();
string sTool;
string sRaw;
string sSound;
string nUsed;
string nXP;
object oPlaceable = OBJECT_SELF;
int nStack = GetAbilityScore(oUser, ABILITY_STRENGTH, FALSE) - GetHardness(oPlaceable);
location lItem = GetLocation(oPlaceable);
float fDelay = 2.5;
float fDelayAction= 300.0;
PrettyDebug(GetName(oPlaceable) + "'s was used by " + GetName(oUser));
if(GetItemInSlot(INVENTORY_SLOT_CWEAPON_B, oUser) == GetItemPossessedBy(oUser, GetLocalString(oPlaceable, sTool)))
{
if(nStack > 0)
{
if(GetLocalInt(oPlaceable, nUsed) != 1)
{
ActionPlayAnimation(ANIMATION_LOOPING_CRAFT01, 1.50, 5.00);
PlaySound(sSound, FALSE);
GiveXPToCreature(oUser, GetLocalInt(oPlaceable, nXP));
CreateItemOnObject(GetLocalString(oPlaceable, sRaw), oUser, nStack, "", TRUE);
SetLocalInt(oPlaceable, nUsed, 1);
DelayCommand(fDelayAction, SetLocalInt(oPlaceable, nUsed, 0));
}
else
{
PrettyError("You have already used this resource out.", fDelay, 16711680);
}
}
else
{
PrettyError("You have too low strenght.", fDelay, 16711680);
}
}
else
{
PrettyError("You don't have the right tool.", fDelay, 16711680);
}
}
#19
Posté 10 octobre 2010 - 12:31
string sTool;
string sRaw;
string sSound;
string nUsed;
string nXP;
The concept is similar to what you did with these other types of things:
object oUser = GetLastUsedBy();
object oPlaceable = OBJECT_SELF;
int nStack = GetAbilityScore(oUser, ABILITY_STRENGTH, FALSE) - GetHardness(oPlaceable);
location lItem = GetLocation(oPlaceable);
float fDelay = 2.5;
float fDelayAction= 300.0;
You need to tell the script what those things in the first list represent, otherwise the script has no idea what they are supposed to be.
Its sort of like if I walked up to you out of nowhere and said "its blue." Well ok sure its blue, but that doesn't help you to know what I'm talking about. I need to tell you what "it" is, and then in that context the fact "its blue" makes more sense...
Modifié par _Knightmare_, 10 octobre 2010 - 12:32 .
#20
Posté 10 octobre 2010 - 04:54
#21
Posté 10 octobre 2010 - 06:46
// Get the Local String Variable set on the Placeable (OBJECT_SELF) that we named "Tool_Type"
string sTool = GetLocalString (OBJECT_SELF, "Tool_Type");
// Get the Local String Variable set on the Placeable (OBJECT_SELF) that we named "Raw_Material"
string sRaw = GetLocalString (OBJECT_SELF, "Raw_Material");
This tells the script to look on the placeable which this script is attached to, look for a variable that we set there, find the value of that variable we entered, and in the rest of this script use/insert that value anywhere we have used "sTool" or "sRaw".
Modifié par _Knightmare_, 10 octobre 2010 - 06:53 .
#22
Posté 22 octobre 2010 - 12:33
// Placeable OnUsed Gain some resources
// Created by: DragonDario
// Created on: 01.10.2010.
/*
Required: Static=FALSE, Usable=TRUE, CurrentHP>0, attach script to the OnUsed event
Suggested: Plot=TRUE, DefaultActionPreference="Use"
*/
//
#include "ginc_debug"
void main()
{
object oUser = GetLastUsedBy();
object oPlaceable = OBJECT_SELF;
string sToolType = GetLocalString(oPlaceable, "sTool");
string sRaw = GetLocalString(oPlaceable, "sMaterial");
string sSoundByJob = GetLocalString(oPlaceable, "sSound");
int nUsed = GetLocalInt(oPlaceable, "sUsed");
int nXP = GetLocalInt(oPlaceable, "nXp");
int nStack = GetAbilityScore(oUser, ABILITY_STRENGTH, FALSE) - GetHardness(oPlaceable);
location lItem = GetLocation(oPlaceable);
float fDelay = 2.5;
float fDelayAction= 300.0;
PrettyDebug(GetName(oPlaceable) + "'s was used by " + GetName(oUser));
if(GetItemInSlot(INVENTORY_SLOT_CWEAPON_B, oUser) == GetItemPossessedBy(oUser, sToolType))
{
if(nStack > 0)
{
if(nUsed != 1)
{
ActionPlayAnimation(ANIMATION_LOOPING_CRAFT01, 1.50, 5.00);
PlaySound(sSoundByJob, FALSE);
GiveXPToCreature(oUser, nXP);
CreateItemOnObject(sRaw, oUser, nStack, "", TRUE);
SetLocalInt(oPlaceable, "sUsed", 1);
DelayCommand(fDelayAction, SetLocalInt(oPlaceable, "sUsed", 0));
}
else
{
PrettyError("You have already used this resource out.", fDelay, 16711680);
}
}
else
{
PrettyError("You have too low strenght.", fDelay, 16711680);
}
}
else
{
PrettyError("You don't have the right tool.", fDelay, 16711680);
}
}
#23
Posté 23 octobre 2010 - 06:44
#24
Posté 24 octobre 2010 - 11:46
#25
Posté 30 octobre 2010 - 02:25
// Placeable OnUsed Gain some resources
// Created by: DragonDario
// Created on: 30.10.2010.
/*
Required: Static=FALSE, Usable=TRUE, CurrentHP>0, attach script to the OnUsed event
Suggested: Plot=TRUE, DefaultActionPreference="Use"
sTool = Tool required to do the job
sMaterial = Product you get
sSound = Sound you get when doing the job
sUsed = Is it used already or not(0 for unused)
nXp = Amount of XP you get by job
*/
//
#include "ginc_debug"
void main()
{
object oUser = GetLastUsedBy();
object oPlaceable = OBJECT_SELF;
string sToolType = GetLocalString(oPlaceable, "sTool");
string sRaw = GetLocalString(oPlaceable, "sMaterial");
string sSoundByJob = GetLocalString(oPlaceable, "sSound");
int nUsed = GetLocalInt(oPlaceable, "sUsed");
int nXP = GetLocalInt(oPlaceable, "nXp");
int nStack = GetAbilityScore(oUser, ABILITY_STRENGTH, FALSE) - GetHardness(oPlaceable);
location lItem = GetLocation(oPlaceable);
float fDelay = 2.5;
float fDelayAction= 300.0;
PrettyDebug(GetName(oPlaceable) + "'s was used by " + GetName(oUser));
if(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oUser) == GetItemPossessedBy(oUser, sToolType) || GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oUser) == GetItemPossessedBy(oUser, sToolType))
{
if(nStack > 0)
{
if(nUsed != 1)
{
ActionPlayAnimation(ANIMATION_LOOPING_CRAFT01, 1.50, 5.00);
PlaySound(sSoundByJob, FALSE);
GiveXPToCreature(oUser, nXP);
CreateItemOnObject(sRaw, oUser, nStack, "", TRUE);
SetLocalInt(oPlaceable, "sUsed", 1);
DelayCommand(fDelayAction, SetLocalInt(oPlaceable, "sUsed", 0));
}
else
{
FloatingTextStringOnCreature("You have already used this resource out.", oUser, FALSE, fDelay);
}
}
else
{
FloatingTextStringOnCreature("You have too low strenght.", oUser, FALSE, fDelay);
}
}
else
{
FloatingTextStringOnCreature("You don't have the right tool.", oUser, FALSE, fDelay);
}
}





Retour en haut







