Need Help Re-scripting. {[Serious Help Only Please]}
#5

Aiight for the restocking part atleast, define a new global constant, set the amount to however many trips you would like to enable a player to make without loading up again

pawn Код:
#define LOAD_UP_MAX = 5 //pick whatever number you like
Then we create a global variable to handle that number for each player.

pawn Код:
new Stock[MAX_PLAYERS] = LOAD_UP_MAX;

Every time they reach a destination, you will need to run this code

pawn Код:
if(Stock[playerid] > 0)
{
 Stock[playerid] = Stock[playerid] - 1;
 GivePlayerMoney(playerid, /*payment earned from the run*/);
 return 1;
}
else
{
 //If they have reached their destination but have no stock on board events here
 return 0;
}
You will then need to make yourself a loadup command, to replenish the stock in the truck.
But before we can do that, ensure you have a function to detect if a player is @ a certain point, such as this one

pawn Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        tempposx = (oldposx -x);
        tempposy = (oldposy -y);
        tempposz = (oldposz -z);
        //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
        {
            return 1;
        }
    }
    return 0;
}
Now that we have a function to detect if a player is @ a certain position, we can produce something like this:


pawn Код:
if(strcmp(cmdtext, "/loadup", true) == 0)
{
    new Float:Radius, Float:LoadX, Float:LoadY, Float:LoadZ; //Define these as global constants, don't leave them here
    LoadX = /*insert your loadup x coord here*/
    LoadY = /*insert your loadup y coord here*/
    LoadZ = /*insert your loadup z coord here*/
    Radius = /*insert a reasonable radius to detect here*/
    //again, make sure you make these global constants, they are just here for demonstration purposes
    if(!PlayerToPoint(Radius, playerid, LoadX, LoadY, LoadZ))
    {
        SendClientMessage(playerid, /*color of your choosing in hex value*/, "You are not at the loading bay!");
        return 0;
    }
    new Cost;
    Cost = /* Cost of the loadup*/;
    if(Stock[playerid] == 0)
    {
        GivePlayerMoney(playerid, -Cost);
        SendClientMessage(playerid, /*color of your choosing in hex value*/, "You have successfully loaded up!");
        Stock[playerid] = STOCK_MAX;
        return 1;
    }
    else
    {
        SendClientMessage(playerid, /*color of your choosing in hex value*/, "You still have stock on board!");
        return 1;
    }
}


As for making the transition between jobs automatic, if you wanna use your current script still
Just use the following @ the end of each job
pawn Код:
OnPlayerCommandText("/job trucker");
e'z
Reply


Messages In This Thread
Need Help Re-scripting. {[Serious Help Only Please]} - by English-Conceptz - 25.11.2011, 13:14
Re: Need Help Re-scripting. {[Serious Help Only Please]} - by Tanush123 - 25.11.2011, 15:08
Re: Need Help Re-scripting. {[Serious Help Only Please]} - by English-Conceptz - 25.11.2011, 15:54
Re: Need Help Re-scripting. {[Serious Help Only Please]} - by English-Conceptz - 26.11.2011, 00:26
Re: Need Help Re-scripting. {[Serious Help Only Please]} - by Rob_Maate - 26.11.2011, 02:21

Forum Jump:


Users browsing this thread: 1 Guest(s)