Solved Problem
#1

Hello, I have a little problem with my truckjob script
I have 5 trucks for the job, so I want you can use them all for the job.

This is the script,(the model ID's are 513,514,515,516,517
#include <a_samp>

#define COLOR_DARKGOLD 0x808000AA
#define COLOR_RED 0xFF0000AA
#define COLOR_YELLOW 0xFFFF00AA

/*new jobtruck[] = {
512,513,514,515,516};*/
new truckjobrunning = 0;
new info;

public OnFilterScriptInit()
{
AddStaticVehicleEx(455,-43.9742,-1155.8762,1.4823,65.0184,-1,-1, 10);
AddStaticVehicleEx(455,-39.6336,-1148.4509,1.5148,62.2225,-1,-1, 10);
AddStaticVehicleEx(455,-37.7033,-1144.2280,1.5173,65.7564,-1,-1, 10);
AddStaticVehicleEx(455,-35.7032,-1140.0637,1.5149,66.4882,-1,-1, 10);
AddStaticVehicleEx(455,-41.9300,-1152.2032,1.5132,62.4657,-1,-1, 10);

info = CreatePickup(1239,1,-70.7099,-1139.1187,1.0781,-1);
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/truck", cmdtext, true, 10) == 0)
{
if(IsPlayerInVehicle(playerid, 513))
{
truckjobrunning = 1;
SetPlayerCheckpoint(playerid, 2058.3142,-2092.4023,9.9832, 10);
GameTextForPlayer(playerid, "~g~You started the job, good luck!", 3000, 3);
return 1;
}
SendClientMessage(playerid, COLOR_RED,"You have to be in a truck to start the job");
}
if (strcmp("/truckinfo", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, COLOR_YELLOW, "You need to bring the truckload to the airport.");
SendClientMessage(playerid, COLOR_YELLOW, "There they will reward you for your help.");
SendClientMessage(playerid, COLOR_YELLOW, "If you enter the truck, type /truck and a red marker will appear.");
SendClientMessage(playerid, COLOR_YELLOW, "Just drive to the marker and you're done.");
return 1;
}
return 0;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(IsPlayerInVehicle(playerid, 513))
{
GivePlayerMoney(playerid, 10000);
GameTextForPlayer(playerid, "~g~You Completed the job, well done!", 3000, 3);
SetVehicleToRespawn(1);
DisablePlayerCheckpoint(playerid);
}
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(IsPlayerInVehicle(playerid, 513))
{
SendClientMessage(playerid, COLOR_RED, "** You can start the truck-mission with /truck");
}
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if((truckjobrunning) == 1)
{
truckjobrunning = 0;
SendClientMessage(playerid, COLOR_RED, "You left your truck behind, get in again if you want to continue your job.");

}else if((truckjobrunning) == 0){

//Nothing
}
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == info)
{
GameTextForPlayer(playerid, "~g~Welcome at the Truck Driver job, use /truckinfo to know more", 3000, 3);
}
}
Reply
#2

pawn Код:
forward IsPlayerInTruck(playerid);
public IsPlayerInTruck(playerid)
{
    if(!IsPlayerInAnyVehicle(playerid))
    {
        SendClientMessage(playerid, 0xFF000000, "You are not in any vehicle");
        return 0;
    }
    if(IsPlayerInVehicle(playerid, 513) || IsPlayerInVehicle(playerid, 514) || IsPlayerInVehicle(playerid, 515) || IsPlayerInVehicle(playerid, 516) || IsPlayerInVehicle(playerid, 517))
    {
        return 1;
    }
    return 0;
}
Replace every if(IsPlayerInVehicle(playerid, 513)) with if(IsPlayerInTruck(playerid)
Reply
#3

No need to make it public, since you don't call it via timer or CallRemoteFunction.
And here's a better way
pawn Код:
IsPlayerInTruck(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        switch(GetPlayerVehicleID(playerid))
        {
            case 513, 514, 515, 516, 517: {return 1;}
            default: {return 0;}
        }
    }
    return 0;
}
Reply
#4

Thanks for you help, but I already fixed it
Reply
#5

By the way, next time use the tags [.pawn] [./pawn] (without dots .) for showing the code like this:
pawn Код:
//code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)