SA-MP Forums Archive
How to make stock stop a script? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to make stock stop a script? (/showthread.php?tid=372545)



How to make stock stop a script? - ddnbb - 27.08.2012

Hi, im using this stock i've made:
pawn Code:
stock GivePlayerDrugs(playerid, amount)
{
    new formatt[64];
    if(PlayerInfo[playerid][pDrugs]+amount > MAX_DRUGS)
    {
        format(formatt, sizeof(formatt), "You cant carry that much drugs! (Limit: %d grams)", MAX_DRUGS);
        return SendMessage(playerid, MSG_ERROR, formatt);
    }
    else
    {
        PlayerInfo[playerid][pDrugs] += amount;
        format(formatt, sizeof(formatt), " *** %s grabs some drugs..", PlayerName(playerid));
        return SendLocalMessage(playerid, COLOR_PURPLE, formatt);
    }
}
And i want to use it like this:
pawn Code:
CMD(playerid, params[])
{
     GivePlayerDrugs(playerid, 100); // So if player cant carry that much drugs,
     OtherFunc(playerid); //--------// then this function and all below wont be called.
     AnotherFunction();
     return 1;
}
Is this possible? How?


Re: How to make stock stop a script? - Kh4led - 27.08.2012

Have you defined MAX_DRUGS?
pawn Code:
#define MAX_DRUGS 100
pawn Code:
CMD(playerid, params[])
{
     GivePlayerDrugs(playerid, =< MAX_DRUGS); // So if player cant carry that much drugs,
     OtherFunc(playerid); //--------// then this function and all below wont be called.
     AnotherFunction();
     return 1;
}
try this


Re: How to make stock stop a script? - ddnbb - 27.08.2012

Quote:
Originally Posted by Kh4led
View Post
Have you defined MAX_DRUGS?
pawn Code:
#define MAX_DRUGS 100
pawn Code:
CMD(playerid, params[])
{
     GivePlayerDrugs(playerid, =< MAX_DRUGS); // So if player cant carry that much drugs,
     OtherFunc(playerid); //--------// then this function and all below wont be called.
     AnotherFunction();
     return 1;
}
try this



Re: How to make stock stop a script? - HuSs3n - 27.08.2012

pawn Code:
stock Check(playerid)
{
   if(PlayerInfo[playerid][pDrugs]+amount > MAX_DRUGS) return 0;
   return 1;
}


CMD:drug(playerid)
{
    new formatt[64];
    if(Check(playerid) == 1)
    {

    }
    else
    {

    }

}



Re: How to make stock stop a script? - ddnbb - 27.08.2012

Quote:
Originally Posted by HuSs3n
View Post
pawn Code:
stock Check(playerid)
{
   if(PlayerInfo[playerid][pDrugs]+amount > MAX_DRUGS) return 0;
   return 1;
}


CMD:drug(playerid)
{
    new formatt[64];
    if(Check(playerid) == 1)
    {

    }
    else
    {

    }

}
I didnt ask for a solution, i just asked if its possible to do it my way. + That is not a good solution.


Re: How to make stock stop a script? - HuSs3n - 27.08.2012

its possible
if you use return 1 in your stock then check in ur cmd if GivePlayerDrugs equals to 1
i dont think its possible in other way (only if you use a new variable)


Re: How to make stock stop a script? - Kh4led - 27.08.2012

Don't help him, he only needs to know if it's possible or not.


Re: How to make stock stop a script? - HB - 27.08.2012

pawn Code:
stock GivePlayerDrugs(playerid, amount)
{
    new formatt[64];
    if(PlayerInfo[playerid][pDrugs]+amount < MAX_DRUGS)
    {
        PlayerInfo[playerid][pDrugs] += amount;
        format(formatt, sizeof(formatt), " *** %s grabs some drugs..", PlayerName(playerid));
        SendLocalMessage(playerid, COLOR_PURPLE, formatt);
        return 1;
    }
    format(formatt, sizeof(formatt), "You can't carry that much drugs! (Limit: %d grams)", MAX_DRUGS);
    SendMessage(playerid, MSG_ERROR, formatt);
    return 0;
}
pawn Code:
CMD(playerid, params[])
{
     if(!GivePlayerDrugs(playerid, 100)) return 1; // So if player cant carry that much drugs,
     OtherFunc(playerid); //--------// then this function and all below wont be called.
     AnotherFunction();
     return 1;
}



Re: How to make stock stop a script? - ddnbb - 27.08.2012

Quote:
Originally Posted by Neozftw
View Post
pawn Code:
stock GivePlayerDrugs(playerid, amount)
{
    new formatt[64];
    if(PlayerInfo[playerid][pDrugs]+amount < MAX_DRUGS)
    {
        PlayerInfo[playerid][pDrugs] += amount;
        format(formatt, sizeof(formatt), " *** %s grabs some drugs..", PlayerName(playerid));
        SendLocalMessage(playerid, COLOR_PURPLE, formatt);
        return 1;
    }
    format(formatt, sizeof(formatt), "You can't carry that much drugs! (Limit: %d grams)", MAX_DRUGS);
    SendMessage(playerid, MSG_ERROR, formatt);
    return 0;
}
pawn Code:
CMD(playerid, params[])
{
     if(!GivePlayerDrugs(playerid, 100)) return 0; // So if player cant carry that much drugs,
     OtherFunc(playerid); //--------// then this function and all below wont be called.
     AnotherFunction();
     return 1;
}
Finally someone who gets me, thanks dude!


Re: How to make stock stop a script? - Unte99 - 27.08.2012

Quote:
Originally Posted by Neozftw
View Post
pawn Code:
stock GivePlayerDrugs(playerid, amount)
{
    new formatt[64];
    if(PlayerInfo[playerid][pDrugs]+amount < MAX_DRUGS)
    {
        PlayerInfo[playerid][pDrugs] += amount;
        format(formatt, sizeof(formatt), " *** %s grabs some drugs..", PlayerName(playerid));
        SendLocalMessage(playerid, COLOR_PURPLE, formatt);
        return 1;
    }
    format(formatt, sizeof(formatt), "You can't carry that much drugs! (Limit: %d grams)", MAX_DRUGS);
    SendMessage(playerid, MSG_ERROR, formatt);
    return 0;
}
pawn Code:
CMD(playerid, params[])
{
     if(!GivePlayerDrugs(playerid, 100)) return 0; // So if player cant carry that much drugs,
     OtherFunc(playerid); //--------// then this function and all below wont be called.
     AnotherFunction();
     return 1;
}
It's not about the money, money, money,
We don't need your money, money, money,
We just wanna make the world dance,
Forget about the price tag....