SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 27/08/2012, 11:52 AM   #1
ddnbb
Huge Clucker
 
ddnbb's Avatar
 
Join Date: May 2011
Posts: 207
Reputation: 40
Default How to make stock stop a script?

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?
ddnbb is offline   Reply With Quote
Old 27/08/2012, 11:59 AM   #2
Kh4led
Banned
 
Join Date: Aug 2012
Posts: 16
Reputation: 0
Default Re: How to make stock stop a script?

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
Kh4led is offline   Reply With Quote
Old 27/08/2012, 12:05 PM   #3
ddnbb
Huge Clucker
 
ddnbb's Avatar
 
Join Date: May 2011
Posts: 207
Reputation: 40
Default Re: How to make stock stop a script?

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
ddnbb is offline   Reply With Quote
Old 27/08/2012, 12:10 PM   #4
HuSs3n
Guest
 
Posts: n/a
Default Re: How to make stock stop a script?

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
    {

    }

}
  Reply With Quote
Old 27/08/2012, 12:12 PM   #5
ddnbb
Huge Clucker
 
ddnbb's Avatar
 
Join Date: May 2011
Posts: 207
Reputation: 40
Default Re: How to make stock stop a script?

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.
ddnbb is offline   Reply With Quote
Old 27/08/2012, 12:20 PM   #6
HuSs3n
Guest
 
Posts: n/a
Default Re: How to make stock stop a script?

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)
  Reply With Quote
Old 27/08/2012, 12:30 PM   #7
Kh4led
Banned
 
Join Date: Aug 2012
Posts: 16
Reputation: 0
Default Re: How to make stock stop a script?

Don't help him, he only needs to know if it's possible or not.
Kh4led is offline   Reply With Quote
Old 27/08/2012, 12:38 PM   #8
HB
Huge Clucker
 
Join Date: Sep 2007
Posts: 486
Reputation: 45
Default Re: How to make stock stop a script?

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;
}
HB is offline   Reply With Quote
Old 27/08/2012, 12:41 PM   #9
ddnbb
Huge Clucker
 
ddnbb's Avatar
 
Join Date: May 2011
Posts: 207
Reputation: 40
Default Re: How to make stock stop a script?

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!
ddnbb is offline   Reply With Quote
Old 27/08/2012, 12:43 PM   #10
Unte99
Gangsta
 
Unte99's Avatar
 
Join Date: Jul 2010
Location: Lithuania
Posts: 629
Reputation: 65
Default Re: How to make stock stop a script?

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....
Unte99 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make an anim not stop? ricardo178 Scripting Help 20 25/05/2012 09:56 PM
make a stock header shorter? The_Gangstas Help Archive 4 24/11/2010 11:03 PM
How to make a stock with input IamNotKoolllll Help Archive 4 24/04/2010 09:17 PM
NPC Question, how to make them stop when I want _Ben_[Fux-c.co.il RP] Help Archive 2 15/10/2009 12:13 PM
stock PlayerIP(playerid), how to make? Remi-X Help Archive 12 23/06/2009 09:48 AM


All times are GMT. The time now is 10:25 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.