@ransomdransomdl wrote:I am attempting to write a script into the Player Castle script tab to provide resources on a given day of the week to Player_1 and the script written reads as follows:
function Time_event()
if(GetDate(DAY_OF_WEEK)==5)then;
GivePlayerResource(PLAYER_1,GOLD,1000);
GivePlayerResource(PLAYER_1,SULFER,10);
end;
When playing the game, the script does not provide the resource to Player_1. Any suggestions of what I am doing wrong.
randsomdl
First, this code belongs in the Map Properties Script tab/(Edit Script), not in the castle's script tab.
Second, you absolutely must enable the console and look at the console screen when you open your map in the game. If follow this suggestion, you will see that your code generates an error. (I made a test map where your code is the only code in the script.)
This error is why your function does not grant the resources. Basically, the game is not even executing your script so the function does not get called. I will admit that the error codes can sometimes be cryptic, but they usually give you a clue as to the nature of the problem.
Third, you absolutely must figure out what is wrong with your code, fix it and compile it over and over again until it the game will compile it without error. If you follow this suggestion, you will find that your code has several problems:
- 1) The parenthesis ==5) is misplaced.
2) Your if statement has a colon after the then.
3) Your if statement lacks an end; statement.
4) The GivePlayerResource() function does not exist.
Code: Select all
function Time_event()
if GetDate(DAY_OF_WEEK) == 5 then
SetPlayerResource(PLAYER_1,GOLD,1000);
SetPlayerResource(PLAYER_1,SULFER,10);
end;
end;
Code: Select all
function Time_event()
if GetDate(DAY_OF_WEEK) == 5 then
SetPlayerResource(PLAYER_1,GOLD,1000);
SetPlayerResource(PLAYER_1,SULFER,10);
end;
end;
Trigger(NEW_DAY_TRIGGER, "Time_event");
Code: Select all
function withdrawYes()
local pGold = GetPlayerResource(PLAYER_1, GOLD);
if bankAccount >= 1000 then
pGold = pGold + 1000
bankAccount = bankAccount - 1000
SetPlayerResource(PLAYER_1, GOLD, pGold);
Play2DSound( "/Sounds/_(Sound)/Interface/Ingame/Buy.xdb#xpointer(/Sound)");
else
MessageBox(path.."notEnoughActtGold.txt", "");
end;
end;