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

Hi guys and girls i have a request and hope someone can help, im still a noob around here so please try to give me more than an explanation, the code would be immense tbh.
Ok so i have this:

NOTE THIS ISNT PHP, I JUST USE THE TAGS TO COLOURS SHOW UP
PHP код:
#include <a_samp>
#define COLOR_DARKGOLD 0x808000AA
#define COLOR_RED 0xFF0000AA
#define COLOR_YELLOW 0xFFFF00AA
new TruckerJob[256];
public 
OnFilterScriptInit()
{
    
AddStaticVehicle(403,2057.3081,-1939.9397,13.9432,270.4501,6,6); //  Truck (Spawn Front)
    
AddStaticVehicle(591,2045.2939,-1939.9041,13.0633,268.2366,6,6); //  Trailer (Spawn Back)
    
AddStaticVehicle(403,2032.4635,-1939.7537,13.9389,271.0817,6,6); //  Truck (Spawn Front)
    
AddStaticVehicle(591,2020.9797,-1940.1196,13.9476,270.5276,6,6); //  Trailer (Spawn Back)
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/job trucker"cmdtexttrue10) == 0)
    {
        if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
        {
            if(!
IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))){ SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!"); return 1; }
            if(
TruckerJob[playerid] != && TruckerJob[playerid] != && TruckerJob[playerid] != 3){ TruckerJob[playerid] = 1; }
            new 
name[MAX_PLAYER_NAME], string[48];
            
GetPlayerName(playeridnamesizeof(name));
            
format(stringsizeof(string), "* %s is now a Trucker."name );
            
SendClientMessageToAll(COLOR_YELLOWstring);
    
// TRUCKER JOB #1
            
if(TruckerJob[playerid] == 1){
                
TruckerJob[playerid] = 2;
                
SetPlayerCheckpoint(playerid,1337.8055,-870.5533,39.3027,10);
                
SendClientMessage(playeridCOLOR_RED"Deliver food supplies to Roboi's Food Mart");
                return 
1;
            }
    
// TRUCKER JOB #2
            
if(TruckerJob[playerid] == 2){
                
TruckerJob[playerid] = 3;
                
SetPlayerCheckpoint(playerid,1003.4263,-941.8485,41.8079,10);
                return 
1;
            }
    
// TRUCKER JOB #3
            
if(TruckerJob[playerid] == 3){
                
TruckerJob[playerid] = 1;
                
SetPlayerCheckpoint(playerid,-97.8173,-1166.7585,2.2650,10);
                return 
1;
            }
            return 
1;
        }
        
SendClientMessage(playeridCOLOR_RED,"You have to be in a Truck cab to start the job");
    }
    return 
0;
}
public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
     if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
     {
         
SendClientMessage(playeridCOLOR_RED"* You can start Trucking by typing /job trucker");
     }
     return 
0;
}
public 
OnPlayerEnterCheckpoint(playerid)
{
     if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
     {
        if(!
IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))){ SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!"); DisablePlayerCheckpoint(playerid); return 1; }
        
GivePlayerMoney(playerid,500);
        
SendClientMessage(playerid,COLOR_YELLOW,"* You have earned $500!");
        
DisablePlayerCheckpoint(playerid);
     }
     return 
1;
}
public 
OnPlayerExitVehicle(playeridvehicleid)
{
    if(
TruckerJob[playerid] > 0)
    {
        
SendClientMessage(playeridCOLOR_RED"* You have left your job, you won't be payed.");
        
DisablePlayerCheckpoint(playerid);
    }

#1
i want to do is re-organise the trucker jobs so that one is picked at random when "/job trucker" command is called. Im also going to add loads more jobs of course i just made 3 for now while ive been testing.

#2
i also need in somewhere when the trailer becomes disconnected during a mission, a client message comes up saying 'Re-connect trailer to continue with mission. Not doing so will result upon failure when checkpoint is reached' and then obviously if the player drives into the checkpoint with out the trailer he gets nothing.

#3 i want the player to go and re-stock supplies to from a warehouse to continue to make deliveries, after say between 5-7 trips (5-7 being picked at random after each time.

#4 i want each mission to flow into the next, at the moment the player has to type the command after each mission =/
Reply
#2

for this i see some problem and use dynamic checkpoint to add more cp
pawn Код:
if (strcmp("/job trucker", cmdtext, true, 10) == 0)
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
        {
            if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))){ SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!"); return 1; }
            if(TruckerJob[playerid] != 1 && TruckerJob[playerid] != 2 && TruckerJob[playerid] != 3){ TruckerJob[playerid] = 1; }

            new name[MAX_PLAYER_NAME], string[48];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "* %s is now a Trucker.", name );
            SendClientMessageToAll(COLOR_YELLOW, string);

    // TRUCKER JOB #1

            else if(TruckerJob[playerid] == 1){
                TruckerJob[playerid] = 2;
                SetPlayerCheckpoint(playerid,1337.8055,-870.5533,39.3027,10);
                SendClientMessage(playerid, COLOR_RED, "Deliver food supplies to Roboi's Food Mart");
                return 1;
            }

    // TRUCKER JOB #2

            else if(TruckerJob[playerid] == 2){
                TruckerJob[playerid] = 3;
                SetPlayerCheckpoint(playerid,1003.4263,-941.8485,41.8079,10);
                return 1;
            }

    // TRUCKER JOB #3

            else if(TruckerJob[playerid] == 3){
                TruckerJob[playerid] = 1;
                SetPlayerCheckpoint(playerid,-97.8173,-1166.7585,2.2650,10);
                return 1;
            }
            return 1;
        }
        SendClientMessage(playerid, COLOR_RED,"You have to be in a Truck cab to start the job");
    }
    return 0;
}
and change trucker job to
pawn Код:
new TruckerJob[MAX_PLAYERS];
if you think i was talking about some next thing just add me on xfire: Tanush
msn: tanush-thebest10@hotmail.com
Reply
#3

added you on msn


anyone else ?
Reply
#4

thread back to 3rd page and still need help....

please can someone help my implement a trucking filterscript....



ANYONE ?
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)