Trailer Problem -
Angel- - 20.05.2011
i want the Trailer 435 When Attached to truck 515 to give the trucker trailer capasity 100
and when the trailer 591 is attached to truck 515 to give the trucker trailer capasity 50
Код:
if(IsATruck(newcar))
{
if(PlayerInfo[playerid][pLeader] == 17 || PlayerInfo[playerid][pMember] == 17)
{
format(string, sizeof(string), "Products: %d/%d", PlayerHaul[newcar][pLoad],PlayerHaul[newcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
SendClientMessage(playerid, COLOR_WHITE, "INFO: You can deliver Products to Businesses.");
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREY,"You don't have keys of this vehicle.");
}
}
Код:
enum pHaul
{
pCapasity,
pLoad,
};
new PlayerHaul[113][pHaul];
Код:
PlayerHaul[108][pCapasity] = 100;
PlayerHaul[109][pCapasity] = 100;
PlayerHaul[110][pCapasity] = 50;
PlayerHaul[111][pCapasity] = 50;
Код:
if(strcmp(cmd, "/buyprods", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new tmpcar = GetPlayerVehicleID(playerid);
new compcost = 20;
if(IsPlayerInRangeOfPoint(playerid, 5, -45.69187,-224.1864,6.515688))
{
if(IsATruck(tmpcar) && IsTrailerAttachedToVehicle(tmpcar)) //Modded
{
if(PlayerHaul[tmpcar][pLoad] < PlayerHaul[tmpcar][pCapasity])
{
new amount;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /buyprods [amount]");
return 1;
}
amount = strval(tmp);
if(amount < 1 || amount > 500) { SendClientMessage(playerid, COLOR_GREY, " Can't buy less then 1 Product or more then 500!"); return 1; }
new check= PlayerHaul[tmpcar][pLoad] + amount;
if(check > PlayerHaul[tmpcar][pCapasity])
{
format(string, sizeof(string), " You went over the Truck Products Carry Limit of %d, you currently carry %d.",PlayerHaul[tmpcar][pCapasity],PlayerHaul[tmpcar][pLoad]);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
new cost = amount*compcost;
if(GetPlayerMoney(playerid) >= cost)
{
PlayerHaul[tmpcar][pLoad] += amount;
format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "You bought %d Products for $%d.", amount,cost);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
GivePlayerCash(playerid,-cost);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
return 1;
}
else
{
format(string, sizeof(string), "You cant afford %d Products at $%d!", amount,cost);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
return 1;
}
}
else
{
format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
return 1;
}
}
else
{
SendClientMessage(playerid, TEAM_GROVE_COLOR, "This Vehicle does not have a trailer to deliver Products.");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not in trucker place.");
return 1;
}
}
return 1;
}
if(strcmp(cmd, "/sellprods", true) == 0)
{
new cashmade;
new tmpcar;
if(IsPlayerConnected(playerid))
{
tmpcar = GetPlayerVehicleID(playerid);
if(!IsATruck(tmpcar) && !IsTrailerAttachedToVehicle(tmpcar)) //Modded
{
GameTextForPlayer(playerid, "~r~You are not in a delivery truck", 5000, 1);
return 1;
}
if(PlayerHaul[tmpcar][pLoad] == 0)
{
GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
return 1;
}
for(new i = 0; i < sizeof(BizzInfo); i++)
{
if (IsPlayerInRangeOfPoint(playerid, 10,BizzInfo[i][bEntranceX], BizzInfo[i][bEntranceY], BizzInfo[i][bEntranceZ]))
{
//printf("Found House :%d",i);
for(new l = PlayerHaul[tmpcar][pLoad]; l > 0; l--)
{
if(BizzInfo[i][bProducts] == BizzInfo[i][bMaxProducts])
{
GameTextForPlayer(playerid, "~r~Our stores are full", 5000, 1);
format(string, sizeof(string), "Cash Earned $%d.", cashmade);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
return 1;
}
if(BizzInfo[i][bPriceProd] > BizzInfo[i][bTill])
{
GameTextForPlayer(playerid, "~r~We Cant Afford The Deal", 5000, 1);
format(string, sizeof(string), "Cash Earned $%d.", cashmade);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
return 1;
}
PlayerHaul[tmpcar][pLoad]--;
BizzInfo[i][bProducts]++;
cashmade = cashmade+BizzInfo[i][bPriceProd];
//ConsumingMoney[playerid] = 1;
GivePlayerCash(playerid,BizzInfo[i][bPriceProd]);
BizzInfo[i][bTill] -= BizzInfo[i][bPriceProd];
if(PlayerHaul[tmpcar][pLoad] == 0)
{
GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
format(string, sizeof(string), "Cash Earned $%d.", cashmade);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
return 1;
}
}
OnPropUpdate();
return 1;
}
}
}
before i changed the vehicles it would read the carid
now i have it so it reads the vehicle model id
this is before i allso changed the type of vehicle used for trucking
Код:
AddStaticVehicleEx(456,2508.9116,-2111.7759,13.7206,0,-1,-1, 30000); // Component Truck Yankee 108
AddStaticVehicleEx(456,2484.5356,-2111.7759,13.7196,0,-1,-1,30000); // Component Truck Yankee 109
AddStaticVehicleEx(440,2529.0413,-2085.3999,13.6651,90,-1,-1,30000); // Component Truck Rumpo 110
AddStaticVehicleEx(440,2528.9482,-2092.6104,13.6631,90,-1,-1,30000); // Component Truck Rumpo 111
this is vehicle before i changed it
Код:
public IsATruck(carid)
{
if(carid >= 201 && carid <= 220)
{
return 1;
}
return 0;
}
and this is now
Код:
stock IsATruck(vehicleid) // By Rick
{
switch(GetVehicleModel(vehicleid))
{
case 515: return 1;
}
return 0;
}
If Some One Could Help Me i Would Be Very Happy I Will Not Be Responding To this Till I am Off Work
Re: Trailer Problem -
Angel- - 21.05.2011
Код:
PlayerHaul[108][pCapasity] = 100;
PlayerHaul[109][pCapasity] = 100;
PlayerHaul[110][pCapasity] = 50;
PlayerHaul[111][pCapasity] = 50;
So It Is Loading Vehicle Ids
Код:
PlayerHaul[435][pCapasity] = 100;
PlayerHaul[591][pCapasity] = 50;
I Need It To Load Model Ids
Then I Need It To Check If The Trailer Is Attached To The Truck Model Id 515
At The Moment It Doesn't Even Have Working Trailers
If you Get In The Truck It Vehicle Id 108 It Says You Have Products 0/100
And That's Without Trailer On
But The Script Has Been Edited So Now It Checks For The Trailer If There's No Trailer
It Wont Let You Buy Any Products
Код:
if(strcmp(cmd, "/buyprods", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new tmpcar = GetPlayerVehicleID(playerid);
new compcost = 20;
if(IsPlayerInRangeOfPoint(playerid, 5, -45.69187,-224.1864,6.515688))
{
if(IsATruck(tmpcar) && IsTrailerAttachedToVehicle(tmpcar)) //Modded
{
if(PlayerHaul[tmpcar][pLoad] < PlayerHaul[tmpcar][pCapasity])
{
new amount;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /buyprods [amount]");
return 1;
}
amount = strval(tmp);
if(amount < 1 || amount > 500) { SendClientMessage(playerid, COLOR_GREY, " Can't buy less then 1 Product or more then 500!"); return 1; }
new check= PlayerHaul[tmpcar][pLoad] + amount;
if(check > PlayerHaul[tmpcar][pCapasity])
{
format(string, sizeof(string), " You went over the Truck Products Carry Limit of %d, you currently carry %d.",PlayerHaul[tmpcar][pCapasity],PlayerHaul[tmpcar][pLoad]);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
new cost = amount*compcost;
if(GetPlayerMoney(playerid) >= cost)
{
PlayerHaul[tmpcar][pLoad] += amount;
format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "You bought %d Products for $%d.", amount,cost);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
GivePlayerCash(playerid,-cost);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
return 1;
}
else
{
format(string, sizeof(string), "You cant afford %d Products at $%d!", amount,cost);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
return 1;
}
}
else
{
format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
return 1;
}
}
else
{
SendClientMessage(playerid, TEAM_GROVE_COLOR, "This Vehicle does not have a trailer to deliver Products.");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not in trucker place.");
return 1;
}
}
return 1;
}
This Is When You Are Trying To Buy Products
And The Truck Part There It Checks The Vehicle
Код:
if(IsATruck(newcar))
{
if(PlayerInfo[playerid][pLeader] == 17 || PlayerInfo[playerid][pMember] == 17)
{
format(string, sizeof(string), "Products: %d/%d", PlayerHaul[newcar][pLoad],PlayerHaul[newcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
SendClientMessage(playerid, COLOR_WHITE, "INFO: You can deliver Products to Businesses.");
SendClientMessage(playerid, COLOR_WHITE, "INFO: Commands are /loadfood");
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREY,"You don't have keys of this vehicle.");
}
}
So What I Am Trying To Do Is Make The Trailer Say This
Код:
if(IsATruck(newcar))
{
if(PlayerInfo[playerid][pLeader] == 17 || PlayerInfo[playerid][pMember] == 17)
{
format(string, sizeof(string), "Products: %d/%d", PlayerHaul[newcar][pLoad],PlayerHaul[newcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
SendClientMessage(playerid, COLOR_WHITE, "INFO: You can deliver Products to Businesses.");
SendClientMessage(playerid, COLOR_WHITE, "INFO: Commands are /loadfood");
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREY,"You don't have keys of this vehicle.");
}
}
If The Truck Is Connected To The Right Trailer I Am Sorry If I am Making This Confusing
Can Some One Please Help