01.02.2019, 19:24
Quote:
Check this: https://forum.sa-mp.com/showpost.php...1&postcount=23
If this does not work, remove the strpack function #Edit I fixed this problem in the repository. |
PHP Code:
Store:RentVehicle(playerid, response, itemid, modelid, price, amount, itemname[])
{
if(!response)
{
SetPVarInt(playerid,"shopping", 0);
return true;
}
if(GetPlayerMoneyEx(playerid) < price)
{
SendClientMessage(playerid, COLOR_ORANGE, "Error: You don't have enough money.");
SetPVarInt(playerid,"shopping", 0);
return true;
}
new veh, string[256];
new sendername[MAX_PLAYER_NAME];
for(new car = 0; car < MAX_VEHICLES; car++)
{
if(rcarInfo[car][Created] == 1)
{
if(strcmp(rcarInfo[car][Owner], sendername, true) == 0)
{
SendClientMessage(playerid, COLOR_ORANGE, "Server: You already rent a car, please use /unrentcar unrent it.");
GivePlayerMoneyEx(playerid, 500);
return 1;
}
}
}
GetPlayerName(playerid, sendername, sizeof(sendername));
veh = CreateVehicle(modelid, 1644.9814, -2322.5200, 13.0420, 89.7556, 0, 0, 0);
SetVehicleVirtualWorld( veh , GetPlayerVirtualWorld(playerid)); // this does NOT return vehicle id.
LinkVehicleToInterior(veh, GetPlayerInterior(playerid)); // I added this to be be on the safe side.
rcarInfo[veh][Created] = 1;
//VehicleInfo[veh][vType] = 3;
strmid(rcarInfo[veh][Owner], sendername, 0, strlen(sendername), 255);
PutPlayerInVehicle(playerid, veh, 0);
VehicleInfo[veh][vWindows] = 0;
VehicleInfo[veh][vLocked] = 0;
RemovePlayerMoneyEx(playerid, price);
format(string, 128, "You have rented a %s, You will be charged every hour $%i. (Only when online)", itemname, price);
SendClientMessage(playerid, COLOR_ORANGE, string);
SendClientMessage(playerid, COLOR_ORANGE, "The car will stay until you finish renting it, use /unrentcar to despawn it");
SetPVarInt(playerid,"shopping", 0);
return true;
}