Trailerchecking on cp and command -
Shaheen - 26.02.2016
hey guys
how to check for eg:
if a player is doing truck mission he should attach a trailer to start a mission ??
Re: Trailerchecking on cp and command -
KillerDVX - 26.02.2016
Make a variable that checks for it, if the variable is on 1, the mission starts.
Re: Trailerchecking on cp and command -
Shaheen - 27.02.2016
didnt understand plz can u give an example code ??
Re: Trailerchecking on cp and command -
Chilli9434 - 27.02.2016
delete double post
Re: Trailerchecking on cp and command -
Chilli9434 - 27.02.2016
Put this under OnPlayerEnterCheckpoint , and obviously link it up with GetPVar (or however you're doing it) and if its true, return what you want to happen, if it isnt true tell the player they need a trailer to do this. Its pretty simple just using IsTrailerAttachedToVehicle
if(IsTrailerAttachedToVehicle(vehicleid))
{
Do stuff
} else {
You need a trailer to do this
}
Re: Trailerchecking on cp and command -
Shaheen - 27.02.2016
double post
removed
Re: Trailerchecking on cp and command -
Shaheen - 28.02.2016
i had made this and created this code but still doesnot works
Код:
#include <a_samp>
#include Truckingmissions
#define COLOR_ORANGE 0xFFA500FF
#define COLOR_LIMEGREEN 0x32CD32FF
#define COLOR_ROYALBLUE 0x4169E1FF
#define COLOR_PINK 0xFA8072FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
enum {
STAGE_IDLE,
STAGE_LOAD,
STAGE_UNLOAD
}
new MissionStage[MAX_PLAYERS];
new Float: gPickupCPs[][] = {
{ 2482.1025,-2115.5769,13.5469},
{ 992.2057,-1376.1956,13.3270 },
{ 887.2043,-1228.4708,16.7225 },
{ -1081.1879,-1625.7737,76.3672 },
{ -1578.6672,91.7932,3.5547 },
{ -1790.5306,1418.1010,7.1875 },
{ 2357.2292,2741.4360,10.8203 },
{ 1610.1963,2326.2185,10.8203 },
{ 988.1158,2139.7402,10.8203 },
{ 1478.4102,1018.5461,10.8203 }
};
new Float: gDeliverCPs[][] = {
{ 380.5093,-1851.8972,7.8359 },
{ -380.2624,-1413.9344,25.7266 },
{ -1896.4308,-1706.3574,21.7564 },
{ -2098.0281,-2240.2974,30.6250 },
{ -2148.3145,-2446.4321,30.6250 },
{ -2131.2305,-157.6189,35.3203 },
{ -2329.2871,-133.7341,35.3203 },
{ -1750.6095,958.5900,24.8828 },
{ 1900.0614,2085.7256,10.8203 },
{ 2441.6106,2005.6488,10.8203 }
};
public OnPlayerConnect(playerid) {
MissionStage[playerid] = STAGE_IDLE;
return true;
}
DeliveryMission(playerid) {
if(MissionStage[playerid] == STAGE_IDLE) {
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 515)
{
if(IsTrailerAttachedToVehicle(435)){
}
new
idx,
Float: tmp,
Float: dist = GetPlayerDistanceFromPoint(playerid, gPickupCPs[0][0], gPickupCPs[0][1], gPickupCPs[0][2])
;
for(new i = 1; i < sizeof gPickupCPs; ++i) {
tmp = GetPlayerDistanceFromPoint(playerid, gPickupCPs[i][0], gPickupCPs[i][1], gPickupCPs[i][2]);
if(tmp < dist) {
dist = tmp;
idx = i;
}
}
MissionStage[playerid] = STAGE_LOAD;
return SetPlayerCheckpoint(playerid, gPickupCPs[idx][0], gPickupCPs[idx][1], gPickupCPs[idx][2], 20.0);
}
} else {
MissionStage[playerid] = STAGE_IDLE;
return DisablePlayerCheckpoint(playerid);
}
return false;
}
public OnPlayerCommandText(playerid, cmdtext[]) {
if (strcmp("/work", cmdtext, true) == 0) {
if(MissionStage[playerid] != STAGE_IDLE) {
return SendClientMessage(playerid, COLOR_RED, "You are already in a work!");
}
if(DeliveryMission(playerid)) {
new
string[64]
;
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 515)
{
}
GetPlayerName(playerid, string, MAX_PLAYER_NAME);
strcat(string, " is now doing Truck Job.");
return SendClientMessageToAll(COLOR_ORANGE, string);
}
}
if (strcmp("/stopwork", cmdtext, true) == 0) {
if(DeliveryMission(playerid)) {
return SendClientMessage(playerid, COLOR_RED, "You had Stopped your Work!");
}
}
return false;
}
public OnPlayerEnterCheckpoint(playerid) {
switch(MissionStage[playerid]) {
case STAGE_LOAD: {
new
rand = random(sizeof gDeliverCPs)
;
if(IsTrailerAttachedToVehicle(435))
{
SendClientMessage(playerid,COLOR_RED, "Get to the unloading Point !")
return true;
}else {
SendClientMessage(playerid,COLOR_RED, "You need Trailer to do tis stuuf !")
}
DisablePlayerCheckpoint(playerid);
GameTextForPlayer(playerid, "~g~Passengers Boarding !", 2000, 4);
TogglePlayerControllable(playerid, false); // Freeze the player
SetTimerEx("Unfreeze", 3000, false, "i", playerid); // Make a 3 second timer for that player to get unfroze
SetPlayerCheckpoint(playerid, gDeliverCPs[rand][0], gDeliverCPs[rand][1], gDeliverCPs[rand][2], 10.0);
MissionStage[playerid] = STAGE_UNLOAD;
}
case STAGE_UNLOAD: {
DisablePlayerCheckpoint(playerid);
{
if(IsTrailerAttachedToVehicle(515))
return true;
}
GameTextForPlayer(playerid, "~g~Passengers UnLoading !", 2000, 4);
TogglePlayerControllable(playerid, false); // Freeze the player
SetTimerEx("Unfreeze", 3000, false, "i", playerid); // Make a 3 second timer for that player to get unfroze
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
new cash = random(10000);
GivePlayerMoney(playerid, cash);
MissionStage[playerid] = STAGE_IDLE;
}
}
return false;
}
public OnPlayerDeath(playerid, killerid, reason){
MissionStage[playerid] = STAGE_IDLE;
DisablePlayerCheckpoint(playerid);
return true;
}
forward Unfreeze(playerid);
public Unfreeze(playerid)
{
TogglePlayerControllable(playerid, true); // Unfreeze the player after 5 seconds
return 1;
}
public OnPlayerFinishMission(playerid)
{
SendClientMessage(playerid, 0x00FF00FF, "You have completed your mission!");
return 1;
}
Re: Trailerchecking on cp and command -
Sew_Sumi - 28.02.2016
Stop pasting up responses to this sort of request... This is Scripting Help, not Scripting Requests.
I'd also be using define for STAGE_IDLE and all that...
Re: Trailerchecking on cp and command -
Shaheen - 28.02.2016
still looking for help
Re: Trailerchecking on cp and command -
Sew_Sumi - 28.02.2016
What stages does it actually hit, and what does it do currently with the code you posted above?
"Doesn't work" is not an answer
As I said though too, I'd use Defines for the STAGE_LOAD STAGE_IDLE e.t.c. They don't need to be enums, as they're only a value, set to STAGE_LOAD, so you can read it.