by Grey-Wolf » Tue Feb 12, 2019 6:33 pm
Sorry, I hate to be "that guy", but I have to resurrect this topic again.
In the end, thanks to KeksDose's help, I managed to get the script working, and now I can make the player read the datalogs and switch between pages.
Another problem emerged (as always): I want the player to be unable to shoot or select any weapon while holding the datalogs in his hands (he would appear with 4 arms otherwise). So i took my chances with this:
Spoiler:Code: Select all
#library "DATALOGS"
#include "zcommon.acs"
#define MAX_PAGES 2
script "IMPLOG" (void)
{
str weapon = GetWeapon();
str log_pages[MAX_PAGES] = { "pdaimp1", "pdaimp2" };
int i = GetUserVariable(0, "user_page_index");
// Flipping pages
if(0 <= i && i < MAX_PAGES)
{
Setweapon("BlankWeapon");
playsound(0,"GOTKEY",0,1.0);
SetFont(log_pages[i]);
SetHudSize(640, 480, true);
HudMessage(s:"a"; HUDMSG_PLAIN|HUDMSG_LAYER_UNDERHUD, 100, CR_UNTRANSLATED, 320.0, 240.0, 0);
i++;
}
// Done reading
else if (StriCmp(weapon, "BlankWeapon") != 0)
{
playsound(0,"GOTKEY",0,1.0);
HudMessage(s:""; 0, 100, 0, 0, 0, 0);
i = 0;
}
else
{
playsound(0,"GOTKEY",0,1.0);
HudMessage(s:""; 0, 100, 0, 0, 0, 0);
i = 0;
}
SetUserVariable(0, "user_page_index", i);
}
// When somebody exits while you're reading, the message gets cleared, so
// the page count should be reset, too.
script "Reset Page" enter
{
SetUserVariable(0, "user_page_index", 0);
}
What I added are the
str weapon = GetWeapon(); in the beginning, and the part after
//Done reading . My idea was to check if the player is holding the blankweapon i made, and if he's NOT holding it, the datalog screen would disappear.
Thing is that when I use the datalog for the first time, the blankweapon is actually selected, so i can't shoot or see any weapon sprite (everything's good until here). But if I try to switch to another weapon WHILE reading, the switch is made normally, and I can see the weapon under the datalog screen (tha of course didn't disappear. So there's obviously something not working somewhere, but I don't know how I should solve it.
One last hint... please?
Sorry, I hate to be "that guy", but I have to resurrect this topic again. In the end, thanks to KeksDose's help, I managed to get the script working, and now I can make the player read the datalogs and switch between pages. Another problem emerged (as always): I want the player to be unable to shoot or select any weapon while holding the datalogs in his hands (he would appear with 4 arms otherwise). So i took my chances with this: [spoiler][code]#library "DATALOGS" #include "zcommon.acs" #define MAX_PAGES 2 script "IMPLOG" (void) { str weapon = GetWeapon(); str log_pages[MAX_PAGES] = { "pdaimp1", "pdaimp2" }; int i = GetUserVariable(0, "user_page_index"); // Flipping pages if(0 <= i && i < MAX_PAGES) { Setweapon("BlankWeapon"); playsound(0,"GOTKEY",0,1.0); SetFont(log_pages[i]); SetHudSize(640, 480, true); HudMessage(s:"a"; HUDMSG_PLAIN|HUDMSG_LAYER_UNDERHUD, 100, CR_UNTRANSLATED, 320.0, 240.0, 0); i++; } // Done reading else if (StriCmp(weapon, "BlankWeapon") != 0) { playsound(0,"GOTKEY",0,1.0); HudMessage(s:""; 0, 100, 0, 0, 0, 0); i = 0; } else { playsound(0,"GOTKEY",0,1.0); HudMessage(s:""; 0, 100, 0, 0, 0, 0); i = 0; } SetUserVariable(0, "user_page_index", i); } // When somebody exits while you're reading, the message gets cleared, so // the page count should be reset, too. script "Reset Page" enter { SetUserVariable(0, "user_page_index", 0); }[/code][/spoiler] What I added are the [b]str weapon = GetWeapon();[/b] in the beginning, and the part after [b]//Done reading[/b]. My idea was to check if the player is holding the blankweapon i made, and if he's NOT holding it, the datalog screen would disappear. Thing is that when I use the datalog for the first time, the blankweapon is actually selected, so i can't shoot or see any weapon sprite (everything's good until here). But if I try to switch to another weapon WHILE reading, the switch is made normally, and I can see the weapon under the datalog screen (tha of course didn't disappear. So there's obviously something not working somewhere, but I don't know how I should solve it. One last hint... please?