Hallo!
Ich habe in meinem Script ein Truckersystem, indem die Trucks, logischerweise, Produkte bekommen. Dies buggt jedoch, also möchte ich das neu machen.
Wenn ich "new trucker[10]"; mache und die Trucks von 0-10 benenne, müsste ich doch von bspw. trucker[4] die Produkte auf bspw. 100 setzen können, oder?
Ich will erzielen, dass Truck XY beim Spawn 0/500 Proudkten bekommt. mit /buyprods (Befehl vorhanden) sollen die Produkte aufgefüllt weerden können, aber nicht mehr als 500.
Wie kann ich die Produkte für die Trucks definen? Hier ein paar Codeschnipsel von dem Ganzen:
SetVehicleNumberPlate(CreateVehicleForServer(455,2793.8962,-2402.4971,14.0687,89.2942,61,61,0,18,4,0), "Trucker"); //Flatbed 35
SetVehicleNumberPlate(CreateVehicleForServer(455,2780.7864,-2402.5027,14.0721,89.6381,61,61,0,18,4,0), "Trucker"); //Flatbed 36
SetVehicleNumberPlate(CreateVehicleForServer(455,2780.0688,-2432.9600,14.0722,90.1512,61,61,0,18,4,0), "Trucker"); //Flatbed 38
SetVehicleNumberPlate(CreateVehicleForServer(455,2793.7683,-2432.9729,14.0687,91.0486,61,61,0,18,4,0), "Trucker"); //Flatbed 39
SetVehicleNumberPlate(CreateVehicleForServer(456,2779.1611,-2471.6335,13.8103,91.3930,61,61,0,18,4,0), "Trucker"); //Yankee 40
SetVehicleNumberPlate(CreateVehicleForServer(456,2793.8464,-2471.4573,13.8110,89.9569,61,61,0,18,4,0), "Trucker"); //Yankee 41
SetVehicleNumberPlate(CreateVehicleForServer(514,2775.4951,-2420.4458,14.2370,90.1054,61,61,0,18,4,0), "Trucker"); //Tanker 42
SetVehicleNumberPlate(CreateVehicleForServer(514,2775.6499,-2415.0483,14.2265,87.8010,61,61,0,18,4,0), "Trucker"); //Tanker 3
enum pHaul
{
pCapasity,
pLoad,
};
new PlayerHaul[100][pHaul];
if(PlayerInfo[playerid][pTruckLic] == 1)
{
format(string, sizeof(string), "Produkte: %d/%d", PlayerHaul[newcar][pLoad],PlayerHaul[newcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
SendClientMessage(playerid, COLOR_WHITE, "INFO: Du kannst Produkte an Firmen liefern.");
SendClientMessage(playerid, COLOR_WHITE, "INFO: Befehle sind: /load /buyprods /sellprods /bpSF /tender");
}
//Prods 500
PlayerHaul[60][pCapasity] = 500;
PlayerHaul[61][pCapasity] = 500;
PlayerHaul[62][pCapasity] = 500;
PlayerHaul[63][pCapasity] = 500;
//Prods 250
PlayerHaul[64][pCapasity] = 250;
PlayerHaul[65][pCapasity] = 250;
//Prods 750
PlayerHaul[66][pCapasity] = 750;
PlayerHaul[67][pCapasity] = 750;
if(strcmp(cmd, "/buyprods", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new tmpcar = GetPlayerVehicleID(playerid);
new compcost = 10;
if(IsPlayerInRangeOfPoint(playerid, 20.0, 2787.2449,-2456.6931,13.6338) || IsPlayerInRangeOfPoint(playerid, 10.0, -2098.9316,-15.6872,35.3203))
{
if(IsATruck(tmpcar))
{
if(PlayerHaul[tmpcar][pLoad] < PlayerHaul[tmpcar][pCapasity])
{
new amount;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "BENUTZUNG: /buyprods [Menge]");
return 1;
}
amount = strval(tmp);
if(amount < 1 || amount > 500)
{
SendClientMessage(playerid, COLOR_GREY, " Du kannst nicht weniger als 1 Produkt oder mehr als 500 Produkte kaufen !");
return 1;
}
new check= PlayerHaul[tmpcar][pLoad] + amount;
if(check > PlayerHaul[tmpcar][pCapasity])
{
format(string, sizeof(string), "Der Truck kann nicht mehr als %d Produkte laden. Deine aktuellen Produkte: %d.",PlayerHaul[tmpcar][pCapasity],PlayerHaul[tmpcar][pLoad]);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
new cost = amount*compcost;
if(PlayerMoney[playerid] >= cost)
{
PlayerHaul[tmpcar][pLoad] += amount;
format(string, sizeof(string), "Produkte: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "Du hast %d Produkte für $%d gekauft.", amount,cost);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
PlayerMoney[playerid] = PlayerMoney[playerid] -= cost;
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
return 1;
}
else
{
format(string, sizeof(string), "Du hats nicht genug Geld dir deine Produkte (%d) für $%dzu kaufen !", amount,cost);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
return 1;
}
}
else
{
format(string, sizeof(string), "Produkte: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
return 1;
}
}
else
{
SendClientMessage(playerid, TEAM_GROVE_COLOR, "Dieses Fahrzeug kann keine Produkte laden.");
return 1;
}
}
else
{
SendClientMessage(playerid,COLOR_GRAD2, "Du kannst hier keine Produkte kaufen. Nur in LS (marker!) oder in SF an der Fahrschule.");
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, 2787.2449,-2456.6931,13.6338, 8.0);
return 1;
}
}
return 1;
}
if(strcmp(cmd, "/sellprods", true) == 0)
{
new cashmade;
new tmpcar;
if(IsPlayerConnected(playerid))
{
tmpcar = GetPlayerVehicleID(playerid);
if(!IsATruck(tmpcar))
{
GameTextForPlayer(playerid, "~r~Du bist in einem Truck", 5000, 1);
return 1;
}
if(PlayerHaul[tmpcar][pLoad] == 0)
{
GameTextForPlayer(playerid, "~r~Dein Truck ist leer, lade ihn wieder voll!", 5000, 1);
format(string, sizeof(string), "Produkte: %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 (PlayerToPoint(10, playerid,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~Wir brauchen keine Produkte!", 5000, 1);
format(string, sizeof(string), "Verdienst: $%d.", cashmade);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "Produkte: %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~Wir können nichts kaufen!", 5000, 1);
format(string, sizeof(string), "Verdienst: $%d.", cashmade);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "Produkte: %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;
PlayerMoney[playerid] = PlayerMoney[playerid] += BizzInfo[i][bPriceProd];
BizzInfo[i][bTill] -= BizzInfo[i][bPriceProd];
if(PlayerHaul[tmpcar][pLoad] == 0)
{
GameTextForPlayer(playerid, "~r~Dein Truck ist leer, lade ihn wieder voll!", 5000, 1);
format(string, sizeof(string), "Verdienst: $%d.", cashmade);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "Produkte: %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;
}
}
}
for(new i = 0; i < sizeof(SBizzInfo); i++)
{
if (PlayerToPoint(10, playerid,SBizzInfo[i][sbEntranceX], SBizzInfo[i][sbEntranceY], SBizzInfo[i][sbEntranceZ]))
{
//printf("Found House :%d",i);
for(new l = PlayerHaul[tmpcar][pLoad]; l > 0; l--)
{
if(SBizzInfo[i][sbProducts] == SBizzInfo[i][sbMaxProducts])
{
GameTextForPlayer(playerid, "~r~Wir brauchen keine Produkte!", 5000, 1);
format(string, sizeof(string), "Verdienst: $%d.", cashmade);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "Produkte: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
return 1;
}
if(SBizzInfo[i][sbPriceProd] > SBizzInfo[i][sbTill])
{
GameTextForPlayer(playerid, "~r~Wir können nichts kaufen!", 5000, 1);
format(string, sizeof(string), "Verdienst: $%d.", cashmade);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "Produkte: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
return 1;
}
PlayerHaul[tmpcar][pLoad]--;
SBizzInfo[i][sbProducts]++;
cashmade = cashmade+SBizzInfo[i][sbPriceProd];
ConsumingMoney[playerid] = 1;
PlayerMoney[playerid] = PlayerMoney[playerid] += SBizzInfo[i][sbPriceProd];
SBizzInfo[i][sbTill] -= SBizzInfo[i][sbPriceProd];
if(PlayerHaul[tmpcar][pLoad] == 0)
{
GameTextForPlayer(playerid, "~r~Dein Truck ist leer, lade ihn wieder voll!", 5000, 1);
format(string, sizeof(string), "Verdienst: $%d.", cashmade);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
format(string, sizeof(string), "Produkte: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
return 1;
}
}
OnPropUpdate();
return 1;
}
}
GameTextForPlayer(playerid, "~r~Du bist an keinem Unternehmen", 5000, 1);
return 1;
}