I'm creating a multi-player map with 8 players.
I'm trying to mod. the gold mines to create a certain amount of gold per day.
Here's the script so far.....
function goodmorning()
local i, p
for i=1,8 do
p = GetObjectOwner("themine1");
if p~=PLAYER_NONE then
SetPlayerResource(p,GOLD,GetPlayerResource(p,GOLD)+49000);
sleep(1);
end;
end;
end;
Trigger(NEW_DAY_TRIGGER,"goodmorning");
Every time I use this, it makes the gold mine disappear.
Can anyone help me with this?
Need help with gold mines HV (TotE)
Need help with gold mines HV (TotE)
Last edited by HellSpawn on 30 Jul 2009, 16:54, edited 3 times in total.
That's strange, because this script is wrong, while the previous was correct
If you have only one gold mine, the script should look like:
unction goodmorning()
local p
p = GetObjectOwner("themine1");
if p~=PLAYER_NONE then
SetPlayerResource(p,GOLD,GetPlayerResource(p,GOLD)+49000);
end;
end;
Trigger(NEW_DAY_TRIGGER,"goodmorning");
Anyway, you can try this script with any object that can have owner. Replace the mine with a dwelling, garrison or town and see what happens. Maybe gold mines are just buggish
If you have only one gold mine, the script should look like:
unction goodmorning()
local p
p = GetObjectOwner("themine1");
if p~=PLAYER_NONE then
SetPlayerResource(p,GOLD,GetPlayerResource(p,GOLD)+49000);
end;
end;
Trigger(NEW_DAY_TRIGGER,"goodmorning");
Anyway, you can try this script with any object that can have owner. Replace the mine with a dwelling, garrison or town and see what happens. Maybe gold mines are just buggish
Well, I've tried to use other objects for the gold but it's not working, so I'm left with the solution of just adding more gold mines.
One more question I've had problems with....
I've been trying to remove the level 40 cap.
I've tried setting it to 0, and I've tried clicking on where it says "Remove Cap".
None of those things work.
Any suggestions?
One more question I've had problems with....
I've been trying to remove the level 40 cap.
I've tried setting it to 0, and I've tried clicking on where it says "Remove Cap".
None of those things work.
Any suggestions?
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
I read that some scripts don't work right in multiplayer. I've only done scripting in single player maps. It is difficult to see why your script would cause a gold mine to disappear just from checking ownership of the mine.
I checked mine ownership in a single player map that I was making (on which my hard drive died) and the mine did not disappear. I was also using labels similar to yours, as I had all the mines on the map named.
Oh, rdeford also has at least one map that checks mine ownership and the mines don't disappear. It is a single player map. Check out his "Mining Tycoon" map.
Click here
Here is one example of a script he uses for mines.
I checked mine ownership in a single player map that I was making (on which my hard drive died) and the mine did not disappear. I was also using labels similar to yours, as I had all the mines on the map named.
Oh, rdeford also has at least one map that checks mine ownership and the mines don't disappear. It is a single player map. Check out his "Mining Tycoon" map.
Click here
Here is one example of a script he uses for mines.
function countMines()
local count = 0;
for i=1, 20 do
if GetObjectOwner("mine"..i) == PLAYER_1 then
count = count + 1;
end;
end;
return count;
end;
I suggest you break up this statement into two steps. Sometimes functions don't like other functions inside them even if it seems you should be able to do it.SetPlayerResource(p,GOLD,GetPlayerResource(p,GOLD)+49000);
If it turns out that multiplayer scripting bugs are the problem then you could add in a quest for the extra gold, set a flag when the quest is completed and give gold accordingly. For example, "capturing" a statute could give a weekly income. Or a bounty quest where defeating a certain type of creature would give you an income bonus. I think there are lots of creative ways to add gold without just adding more gold mines, although there is nothing wrong with that, especially if you intend on players being able to hurt each other with raids on mines.Pgold = GetPlayerResource (p, 6) + 49000 -- 6=Gold
SetPlayerResource (p, 6, Pgold);
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
Who is online
Users browsing this forum: No registered users and 7 guests