Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   savelines (https://forums.graalonline.com/forums/showthread.php?t=63540)

Andy0687 01-18-2006 11:57 PM

savelines
 
Having trouble with savelines and the only thing I found from forum search is one thread that didnt quite explain it (Although i tried to user similar style).

Anyways I am trying to write to a file on the server, and when it creates the file it creates it as an empty file, and later nothing is added either.

I have tried it both clientside and serverside and the file created is 0kb

I have done it from the onCreated and onActionserverside.

Not so sure if this is a bug or If I am doing something wrong.

NPC Code:

function onActionServerside() {
if (params[0] == 0) {
write = params[1];
write.savelines("test.txt", 0);
}
}
//#CLIENTSIDE
function onplayerchats() {
test = player.chat;
triggeraction(playerx, playery, "serverside", "James/Test", 0, test);
}


Yen 01-19-2006 12:20 AM

That should work.
'write' may be predefined, that's the only reason I can think of for it not to work. You could also try sending player.chat directly, but I don't see why test would be predefined. :/

Andy0687 01-19-2006 12:32 AM

Changed the variable names and have also sent player.chat directly as you suggested, I still am getting a 0 on the filesize, and nothing is being written.

This is not only on the serverside but clientside as well.

I also restarted my gserver and npcserver when i was testing this intially.

napo_p2p 01-19-2006 07:37 AM

It is possible that savelines only works with arrays.

Sacred Shadow 01-19-2006 04:45 PM

Try loading the lines before you save them.

Admins 01-19-2006 06:49 PM

May be you use savestring()
savelines() is saving an array, you would need to add() something before.

Andy0687 01-20-2006 01:48 AM

Quote:

Originally Posted by Stefan
May be you use savestring()
savelines() is saving an array, you would need to add() something before.

I didnt see this documented anywhere, guess now that its here this will help someone else, but yeah using an array did fix it.

Thanks


All times are GMT +2. The time now is 05:19 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.