UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

How could I detect if the player has a perk already

broken avatar :(
Created 7 years ago
by Big-Beautiful
0 Members and 1 Guest are viewing this topic.
2,097 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 25 May 2015
Last active: 5 years ago
Posts
31
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
i hate mei
Signature
Must be kept sacred, heavenly eggs
Mustn’t be desecrated with egg bootlegs
×
Big-Beautiful's Groups
Big-Beautiful's Contact & Social Linksfortress-of-branitude
I'm trying to script a shootable perk bottle to give you a perk with reckfullies shootable trigger script, but modified.
Code Snippet
Plaintext
#using scripts\zm\_zm_perks;
#insert scripts\zm\_zm_perks.gsh;

function init()
{
    level.shoot_quick_revive = 0;

    level thread shootable_perk_1();
}

function shootable_perk_1(player)
{
    trig_1 = GetEnt("shoot_perk_trig", "targetname");

    trig_1 SetHintString("");
    trig_1 SetCursorHint("HINT_NOICON");

    while(1)
    {
    while(1)
    {
        trig_1 waittill("trigger", player);

        IPrintLn("you have perk now ya boy");
player zm_perks::give_perk( PERK_QUICK_REVIVE, false );

        break;
    }
    }

 }

It gives me the perk, but I would like to have an if/else statement so it would display a different message if you already have the perk. I don't know what to put on the "if" part, can someone help me? thanks
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 3 years ago
Posts
306
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
I'm trying to script a shootable perk bottle to give you a perk with reckfullies shootable trigger script, but modified.
Spoiler: click to open...
Code Snippet
Plaintext
#using scripts\zm\_zm_perks;
#insert scripts\zm\_zm_perks.gsh;

function init()
{
    level.shoot_quick_revive = 0;

    level thread shootable_perk_1();
}

function shootable_perk_1(player)
{
    trig_1 = GetEnt("shoot_perk_trig", "targetname");

    trig_1 SetHintString("");
    trig_1 SetCursorHint("HINT_NOICON");

    while(1)
    {
    while(1)
    {
        trig_1 waittill("trigger", player);

        IPrintLn("you have perk now ya boy");
player zm_perks::give_perk( PERK_QUICK_REVIVE, false );

        break;
    }
    }

 }

It gives me the perk, but I would like to have an if/else statement so it would display a different message if you already have the perk. I don't know what to put on the "if" part, can someone help me? thanks
You can use an engine function for this I'm pretty sure, just do:
Code Snippet
Plaintext
if (player HasPerk(PERK_QUICK_REVIVE))
{
//Do Something
}

The names do seem to be exactly the same.
Last Edit: October 24, 2016, 05:32:05 pm by reckfullies
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 25 May 2015
Last active: 5 years ago
Posts
31
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
i hate mei
×
Big-Beautiful's Groups
Big-Beautiful's Contact & Social Linksfortress-of-branitude
Thank you, it worked perfectly. I have a problem though because I found out that you can get the perk while you are down. How could I change if (player HasPerk(PERK_QUICK_REVIVE)) so it detects if you have the perk OR if you are down?
Code Snippet
Plaintext
function shootable_perk_1(player)
{
    trig_1 = GetEnt("perktrig_quick", "targetname");

    trig_1 SetHintString("");
    trig_1 SetCursorHint("HINT_NOICON");

    while(1)
    {
    while(1)
    {
        trig_1 waittill("trigger", player);

        if (player HasPerk(PERK_QUICK_REVIVE))
{
IPrintLn("no no no you can not have the perko");
wait(3);
}
else
{
        IPrintLn("your pals go up fast now");
player zm_perks::give_perk( PERK_QUICK_REVIVE, false );
wait(3);
}

        break;
    }
    }

 }
This is the script now.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 3 years ago
Posts
306
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
Thank you, it worked perfectly. I have a problem though because I found out that you can get the perk while you are down. How could I change if (player HasPerk(PERK_QUICK_REVIVE)) so it detects if you have the perk OR if you are down?
Spoiler: click to open...
Code Snippet
Plaintext
function shootable_perk_1(player)
{
    trig_1 = GetEnt("perktrig_quick", "targetname");

    trig_1 SetHintString("");
    trig_1 SetCursorHint("HINT_NOICON");

    while(1)
    {
    while(1)
    {
        trig_1 waittill("trigger", player);

        if (player HasPerk(PERK_QUICK_REVIVE))
{
IPrintLn("no no no you can not have the perko");
wait(3);
}
else
{
        IPrintLn("your pals go up fast now");
player zm_perks::give_perk( PERK_QUICK_REVIVE, false );
wait(3);
}

        break;
    }
    }

 }
This is the script now.

This should work(Haven't tested it though):
Code Snippet
Plaintext
if(IsAlive(player))
{
    // Do Stuff
}

So you would do:
Code Snippet
Plaintext
if (player HasPerk(PERK_QUICK_REVIVE) || !IsAlive(player))
{
IPrintLn("no no no you can not have the perko");
wait(3);
}
else
{
        IPrintLn("your pals go up fast now");
player zm_perks::give_perk( PERK_QUICK_REVIVE, false );
wait(3);
}
Last Edit: October 24, 2016, 05:34:02 pm by reckfullies
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 25 May 2015
Last active: 5 years ago
Posts
31
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
i hate mei
×
Big-Beautiful's Groups
Big-Beautiful's Contact & Social Linksfortress-of-branitude
IsAlive doesnt seem to work, I am still able to receive the perk when down. I happened to find another function IsInSecondChance so i tried it:
 
Code Snippet
Plaintext
if (player HasPerk(PERK_QUICK_REVIVE) || player IsInSecondChance())

It didn't work either.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 3 years ago
Posts
306
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
IsAlive doesnt seem to work, I am still able to receive the perk when down. I happened to find another function IsInSecondChance so i tried it:
 
Code Snippet
Plaintext
if (player HasPerk(PERK_QUICK_REVIVE) || player IsInSecondChance())

It didn't work either.

Guess they changed how to worked or something since I'm pretty sure that was how you did it in waw.

I guess you could try this, I haven't tested it but here is the function from the scripting api:
Last Edit: October 25, 2016, 03:04:13 am by reckfullies

 
Loading ...