void main()
{// Update script for locking certain player
// drawstring(220,130,3, getindexedvar(0));
// drawstring(220,150,3, getindexedvar(1));
if(openborvariant("in_selectscreen")==1){
int models_cached = openborvariant("models_cached");
int i = 0;
int C = getglobalvar("Load");
for( i = 0; i < models_cached; ++i ) {
char model = getmodelproperty(i,2);
if( model == "Paladin" && C != 39 ) {
changemodelproperty(i,4,0);
return;
}
}
} else if(openborvariant("in_menuscreen")==1){
setindexedvar(0, NULL());
}
}
void oncreate()
{
int C = fileskim("Rise");
setglobalvar("Load", C);
setindexedvar(1, 0);
}
void fileskim(char Line)
{
void file = openfilestream("Test.txt", 1);
void vLoad;
if(file != -1){
setfilestreamposition(file, 0);
vLoad = getfilestreamargument(file, 0, "string");
while(vLoad != Line && vLoad != "#End"){
filestreamnextline(file);
vLoad = getfilestreamargument(file, 0, "string");
}
if( vLoad == Line ){
filestreamnextline(file);
vLoad = getfilestreamargument(file, 0, "int");
return vLoad;
closefilestream(file);
} else if(vLoad == "#End"){
closefilestream(file);
return 0;
}
} else {
return 0;
}
}
if( model == "Paladin" && C != 39 ) {
changemodelproperty(i,4,0);
Bloodbane said:stuff
...
if(openborvariant("in_selectscreen")==1){
int models_cached = openborvariant("models_cached");
int i = 0;
int C = getglobalvar("Lock1");
int D = getglobalvar("Lock2");
int E = getglobalvar("Lock3");
for( i = 0; i < models_cached; ++i ) {
char model = getmodelproperty(i,2);
if( model == "Paladin" && C != 39 ) {
changemodelproperty(i,4,0);
} else if( model == "Rogue" && D != 47 ) {
changemodelproperty(i,4,0);
} else if( model == "Bard" && E != 18 ) {
changemodelproperty(i,4,0);
}
}
...
void main()
{// Update script for locking certain player
// drawstring(220,130,3, getindexedvar(0));
// drawstring(220,150,3, getindexedvar(1));
if(openborvariant("in_selectscreen")==1){
int models_cached = openborvariant("models_cached");
int i = 0;
int C = getglobalvar("Lock1");
int D = getglobalvar("Lock2");
int E = getglobalvar("Lock3");
for( i = 0; i < models_cached; ++i ) {
char model = getmodelproperty(i,2);
if( model == "1" && C != 38 ) {
changemodelproperty(i,4,0);
} else if( model == "2" && D != 48 ) {
changemodelproperty(i,4,0);
} else if( model == "3" && E != 58 ) {
changemodelproperty(i,4,0);
}
}
} else if(openborvariant("in_menuscreen")==1){
setindexedvar(0, NULL());
}
}
void oncreate()
{
int C = fileskim("Rise");
setglobalvar("Lock1", C);
int D = fileskim("Rise2");
setglobalvar("Lock2", D);
int E = fileskim("Rise3");
setglobalvar("Lock3", E);
setindexedvar(1, 0);
}
void writedefault(void Path)
{// Writes file by name Path with default values
// Used when there's no file to start with
void file = createfilestream();
filestreamappend(file, 11, 1);
filestreamappend(file, 22, 0);
filestreamappend(file, 33, 0);
filestreamappend(file, 44, 0);
filestreamappend(file, "Lock1", 0);
filestreamappend(file, "Lock2", 0);
filestreamappend(file, "Lock3", 0);
filestreamappend(file, 8, 0);
filestreamappend(file, 55, 0);
filestreamappend(file, "Rise", 0);
filestreamappend(file, "Rise2", 0);
filestreamappend(file, "Rise3", 0);
filestreamappend(file, 77, 0);
filestreamappend(file, "#End", 0);
savefilestream(file, Path);
closefilestream(file);
}
void Unlock(int Flag, void Path)
{ // Unlocks certain character based on flag and write the status on file named Path
// 1: Unlocks 1
void file = openfilestream(Path, 1);
char Code;
int Value;
void file = openfilestream(Path, 2);
char Code;
int Value;
void file = openfilestream(Path, 3);
char Code;
int Value;
if(Flag == 1){
Code = "Rise";
Value = 38;
} else if(Flag == 2){
Code = "Rise2";
Value = 48;
} else if(Flag == 3){
Code = "Rise3";
Value = 58;
}
anim death
@script
if(frame==1){
setglobalvar("Lock1", 38);
} else if(frame==2){
setglobalvar("Lock2", 48);
} else if(frame==3){
setglobalvar("Lock3", 58);
}
@end_script
loop 0
offset 90 192
delay 1
frame data/chars/x/pain.gif
@cmd Unlock 1 "Test.txt"
frame data/chars/x/pain.gif
@cmd Unlock 2 "Test.txt"
frame data/chars/x/pain.gif
@cmd Unlock 3 "Test.txt"
frame data/chars/x/pain.gif
void file = openfilestream(Path, 1);
char Code;
int Value;
void file = openfilestream(Path, 2);
char Code;
int Value;
void file = openfilestream(Path, 3);
char Code;
int Value;
void file = openfilestream(Path, 1);
char Code;
int Value;
void writedefault(void Path)
{// Writes file by name Path with default values
// Used when there's no file to start with
void file = createfilestream();
filestreamappend(file, 11, 1);
filestreamappend(file, 22, 0);
filestreamappend(file, 33, 0);
filestreamappend(file, 44, 0);
filestreamappend(file, "Lock", 0);
filestreamappend(file, 8, 0);
filestreamappend(file, 55, 0);
filestreamappend(file, "Rise", 0);
filestreamappend(file, 127, 0);
filestreamappend(file, "Rise2", 0);
filestreamappend(file, 85, 0);
filestreamappend(file, "Rise3", 0);
filestreamappend(file, 77, 0);
filestreamappend(file, "#End", 0);
savefilestream(file, Path);
closefilestream(file);
}
void main()
{// Update script for locking certain player
// drawstring(220,130,3, getindexedvar(0));
// drawstring(220,150,3, getindexedvar(1));
if(openborvariant("in_selectscreen")==1){
int models_cached = openborvariant("models_cached");
int i = 0;
int C = getglobalvar("Lock1");
int D = getglobalvar("Lock2");
int E = getglobalvar("Lock3");
for( i = 0; i < models_cached; ++i ) {
char model = getmodelproperty(i,2);
if( model == "1" && C != 39 ) {
changemodelproperty(i,4,0);
} else if( model == "2" && D != 49 ) {
changemodelproperty(i,4,0);
} else if( model == "3" && E != 59 ) {
changemodelproperty(i,4,0);
}
}
} else if(openborvariant("in_menuscreen")==1){
setindexedvar(0, NULL());
}
}
void oncreate()
{
int C = fileskim("Rise");
setglobalvar("Lock1", C);
int D = fileskim("Rise2");
setglobalvar("Lock2", D);
int E = fileskim("Rise3");
setglobalvar("Lock3", E);
setindexedvar(1, 0);
}
void fileskim(char Line)
{
void file = openfilestream("Test.txt", 1);
void vLoad;
if(file != -1){
setfilestreamposition(file, 0);
vLoad = getfilestreamargument(file, 0, "string");
while(vLoad != Line && vLoad != "#End"){
filestreamnextline(file);
vLoad = getfilestreamargument(file, 0, "string");
}
if( vLoad == Line ){
filestreamnextline(file);
vLoad = getfilestreamargument(file, 0, "int");
return vLoad;
closefilestream(file);
} else if(vLoad == "#End"){
closefilestream(file);
return 0;
}
} else {
return 0;
}
}
void fileread(void Path)
{// Read values from file defined with Path then store each value in each entity variable
void self = getlocalvar("self");
void file = openfilestream(Path, 1);
void vLoad;
int i = 0;
if( file != -1 ){
setfilestreamposition(file, 0);
vLoad = getfilestreamargument(file, 0, "string");
while(vLoad != "#End"){
setentityvar(self, i, vLoad);
i = i + 1;
filestreamnextline(file);
vLoad = getfilestreamargument(file, 0, "string");
}
if(vLoad == "#End"){
setentityvar(self, i, vLoad);
closefilestream(file);
}
return 1;
} else {
return -1;
}
}
void fileedit(void Path, char Name, void Value)
{// Read values from entity variables, find the one matching with Name then change the value in next line
void self = getlocalvar("self");
int Check = fileread(Path);
int i;
void vLoad;
if(Check==1){
i = 0;
vLoad = getentityvar(self, i);
while(vLoad != Name && vLoad != "#End" && vLoad != NULL()){
i = i + 1;
vLoad = getentityvar(self, i);
}
if(vLoad == Name){
i = i + 1;
vLoad = getentityvar(self, i);
setentityvar(self, i, Value);
}
}
}
void filewrite(void Path)
{// Read values from entity variables then write them to a file by name Path
// Must use fileread function first
void self = getlocalvar("self");
int i = 0;
void vLoad = getentityvar(self, i);
if(vLoad){
void file = createfilestream();
filestreamappend(file, vLoad, 1);
while(vLoad != "#End" && vLoad != NULL()){
i = i + 1;
vLoad = getentityvar(self, i);
filestreamappend(file, vLoad, 0);
}
savefilestream(file, Path);
closefilestream(file);
}
}
void writedefault(void Path)
{// Writes file by name Path with default values
// Used when there's no file to start with
void file = createfilestream();
filestreamappend(file, 11, 1);
filestreamappend(file, 22, 0);
filestreamappend(file, 33, 0);
filestreamappend(file, 44, 0);
filestreamappend(file, "Lock1", 0);
filestreamappend(file, 8, 0);
filestreamappend(file, 55, 0);
filestreamappend(file, "Rise", 0);
filestreamappend(file, 127, 0);
filestreamappend(file, "Rise2", 0);
filestreamappend(file, 85, 0);
filestreamappend(file, "Rise3", 0);
filestreamappend(file, 77, 0);
filestreamappend(file, "#End", 0);
savefilestream(file, Path);
closefilestream(file);
}
int load_unlocked_model(char modelname)
{
int models_cached = openborvariant("models_cached");
int i = 0;
for ( i = 0; i < models_cached; ++i ) {
char model = getmodelproperty(i,2);
if ( model == modelname ) {
if (getmodelproperty(i,4)!=1) {
loadmodel(modelname);
changemodelproperty(i,4,1);
}
return;
}
}
}
void Unlock(int Flag, void Path)
{ // Unlocks certain character based on flag and write the status on file named Path
// 1: Unlocks 1
void file = openfilestream(Path, 1);
char Code;
int Value;
if(Flag == 1){
Code = "Rise";
Value = 39;
} else if(Flag == 2){
Code = "Rise2";
Value = 49;
} else if(Flag == 3){
Code = "Rise3";
Value = 59;
}
if(file == -1){
writedefault(Path);
}
fileedit(Path, Code, Value);
filewrite(Path);
}
I see, but the thing is that I noticed you changed "Load" to "Lock1,2,3" in your last example, so I simply followed what you did there.And although changing name of global variable isn't wrong, I need to tell you that global variable name in update.c is completely unrelated to texts written in saved file
That's why I simply use "Load"
can anyone make this work
void main()
{// Update script for locking certain player
// drawstring(220,130,3, getindexedvar(0));
// drawstring(220,150,3, getindexedvar(1));
if(openborvariant("in_selectscreen")==1){
int models_cached = openborvariant("models_cached");
int i = 0;
int C = getglobalvar("Load");
int D = getglobalvar("Load2");
int E = getglobalvar("Load3");
for( i = 0; i < models_cached; ++i ) {
char model = getmodelproperty(i,2);
if( model == "1" && C != 39 ) {
changemodelproperty(i,4,0);
} else if( model == "2" && D != 49 ) {
changemodelproperty(i,4,0);
} else if( model == "3" && E != 59 ) {
changemodelproperty(i,4,0);
}
}
} else if(openborvariant("in_menuscreen")==1){
setindexedvar(0, NULL());
}
}
void oncreate()
{
int C = fileskim("Rise");
setglobalvar("Load", C);
int D = fileskim("Rise2");
setglobalvar("Load2", D);
int E = fileskim("Rise3");
setglobalvar("Load3", E);
setindexedvar(1, 0);
}
void writedefault(void Path)
{// Writes file by name Path with default values
// Used when there's no file to start with
void file = createfilestream();
filestreamappend(file, 11, 1);
filestreamappend(file, 22, 0);
filestreamappend(file, 33, 0);
filestreamappend(file, 44, 0);
filestreamappend(file, "Lock", 0);
filestreamappend(file, 8, 0);
filestreamappend(file, 55, 0);
filestreamappend(file, "Rise", 0);
filestreamappend(file, 127, 0);
filestreamappend(file, "Rise2", 0);
filestreamappend(file, 85, 0);
filestreamappend(file, "Rise3", 0);
filestreamappend(file, 77, 0);
filestreamappend(file, "#End", 0);
savefilestream(file, Path);
closefilestream(file);
}
void Unlock(int Flag, void Path)
{ // Unlocks certain character based on flag and write the status on file named Path
// 1: Unlocks 1
// 2: Unlocks 2
// 3: Unlocks 3
void file = openfilestream(Path, 1);
char Code;
int Value;
if(Flag == 1){
Code = "Rise";
Value = 39;
} else if(Flag == 2){
Code = "Rise2";
Value = 49;
} else if(Flag == 3){
Code = "Rise3";
Value = 59;
}
if(file == -1){
writedefault(Path);
}
fileedit(Path, Code, Value);
filewrite(Path);
}
anim death
@script
if(frame==1){
setglobalvar("Load", 39);
} else if(frame==2){
setglobalvar("Load2", 49);
} else if(frame==3){
setglobalvar("Load3", 59);
}
@end_script
loop 0
offset 90 192
delay 1
frame data/chars/x/pain.gif
@cmd Unlock 1 "Test.txt"
frame data/chars/x/pain.gif
@cmd Unlock 2 "Test.txt"
frame data/chars/x/pain.gif
@cmd Unlock 3 "Test.txt"
frame data/charsx/pain.gif
nsw25 said:why cant this be fixed and hardcoded to the openbor engine instead of convoluted workarounds.
skipselect and custom select menus should give this effect but the save games do not load.
can anyone make this work
...
if(openborvariant("in_selectscreen")==1){
int models_cached = openborvariant("models_cached");
void Set = openborvariant("current_set");
int i = 0;
int C = getglobalvar("Lock1");
int D = getglobalvar("Lock2");
int E = getglobalvar("Lock3");
for( i = 0; i < models_cached; ++i ) {
char model = getmodelproperty(i,2);
if( model == "Paladin" && C != 39 ) {
changemodelproperty(i,4,0);
} else if( model == "Rogue" && D != 47 && Set != 2) {
changemodelproperty(i,4,0);
} else if( model == "Bard" && E != 18 && Set != 2) {
changemodelproperty(i,4,0);
}
}
...