%i=1;
while(%i<=$RPG_savecount){
%file.writeline("DATA" SPC $RPG_save[%i] SPC %client.rpg_v[$RPG_save[%i]]);
%i++;
}
function RPG_addvalue(%what){
$RPG_savecount++;
$RPG_save[$RPG_savecount]=%what;
}
while(!%file.isEOF()){
%curline=%file.readline();
switch$(firstWord(%curline)){
case "DATA": %t=restWords(%curline); %client.rpg_v[getword(%t,0)]=getword(%t,1);
}
}
RPG_addvalue("Bow_ammo");
%ammo=%client.rpg_v["Bow_ammo"];
if(%ammo <= 0){
return;//no ammo
}
%client.rpg_v["Bow_ammo"]--;
package RPG_autosave
{
function GameConnection::onClientEnterGame(%this){
Parent::onClientEnterGame(%this);
servercmdLoadRPG(%this);
}
function GameConnection::OnClientLeaveGame(%this){//This tends to exclude the host, however.
serverCmdSaveRPG(%this);
Parent::onClientLeaveGame(%this);
}
};