02.11.2014, 11:06
I have a problem with my /accept car command because a player can own 4 cars maximum and there are 4 slots.
If i sell my infernus (which is on SLOT 4) and the targetid( the person who type /accept car ) has too a car on SLOT 4 it's saying to him "You already own a vehicle." because he already has slot 4 occupied and the other slots not.
So i want to make a switch or helping me make a switch case who puts the car on an empty slot of the targetid when he accepts.
I give rep++ who will help me finish this.
If i sell my infernus (which is on SLOT 4) and the targetid( the person who type /accept car ) has too a car on SLOT 4 it's saying to him "You already own a vehicle." because he already has slot 4 occupied and the other slots not.
So i want to make a switch or helping me make a switch case who puts the car on an empty slot of the targetid when he accepts.
pawn Код:
else if(strcmp(params, "car", true) == 0) {
new giveCarString[128],/*giveCarString2[128],*/x,giveCarPlayerName[2][MAX_PLAYER_NAME];
if(primesccar[playerid] == 1)
{
if(IsPlayerConnectedEx(ofercar[playerid]))
{
if(playerVariables[playerid][pCarModel1] < 1)
{
if(IsPlayerInRangeOfPlayer(playerid, ofercar[playerid], 5.0))
{
GetVehiclePos(playerVariables[ofercar[playerid]][pCarID1], playerVariables[playerid][pCarPos1][0], playerVariables[playerid][pCarPos1][1], playerVariables[playerid][pCarPos1][2]);
GetVehicleZAngle(playerVariables[ofercar[playerid]][pCarID1], playerVariables[playerid][pCarPos1][3]);
playerVariables[playerid][pCarModel1] = playerVariables[ofercar[playerid]][pCarModel1]; // Transfer the car model
playerVariables[playerid][pCarColour1][0] = playerVariables[ofercar[playerid]][pCarColour1][0]; // And the colours, and paint job
playerVariables[playerid][pCarColour1][1] = playerVariables[ofercar[playerid]][pCarColour1][1];
playerVariables[playerid][pCarPaintjob] = playerVariables[ofercar[playerid]][pCarPaintjob];
playerVariables[playerid][pCarKM] = playerVariables[ofercar[playerid]][pCarKM];
while(x < 13)
{
playerVariables[playerid][pCarMods1][x] = GetVehicleComponentInSlot(playerVariables[ofercar[playerid]][pCarID1], x); // Mods, too.
x++;
}
x = 0;
GetPlayerName(ofercar[playerid], giveCarPlayerName[1], MAX_PLAYER_NAME);
GetPlayerName(playerid, giveCarPlayerName[0], MAX_PLAYER_NAME);
playerVariables[playerid][pMoney] -= cardiff[playerid];
playerVariables[ofercar[playerid]][pMoney] += cardiff[playerid];
format(giveCarString, sizeof(giveCarString), "%s has accepted your offer, and is now the owner of this %s.", giveCarPlayerName[0], VehicleNames[playerVariables[playerid][pCarModel1] - 400]);
SendClientMessage(ofercar[playerid], COLOR_WHITE, giveCarString);
format(giveCarString, sizeof(giveCarString), "You have accepted %s's offer, and are now the owner of this %s.", giveCarPlayerName[1], VehicleNames[playerVariables[playerid][pCarModel1] - 400]);
SendClientMessage(playerid, COLOR_WHITE, giveCarString);
new wakaname[25];
GetPlayerName(playerid,wakaname,25);
new str2[128];
format(str2,128,"UPDATE `playeraccounts` SET `playerCarModel`='%d' WHERE `playerName`='%s'",playerVariables[playerid][pCarModel1],wakaname);
mysql_tquery(handle,str2);
new saveQuery[500];
format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarColour1 = '%d', playerCarColour2 = '%d', playerCarPosX = '%f', playerCarPosY = '%f', playerCarPosZ = '%f', playerCarPosZAngle = '%f' WHERE playerName = '%d'",playerVariables[playerid][pCarColour1][0],playerVariables[playerid][pCarColour1][1],
playerVariables[playerid][pCarPos1][0],playerVariables[playerid][pCarPos1][1],playerVariables[playerid][pCarPos1][2],playerVariables[playerid][pCarPos1][3], wakaname);
mysql_tquery(handle,saveQuery);
DestroyPlayerVehicle(ofercar[playerid]);
SpawnPlayerVehicle(playerid);
ofercar[playerid] = -1;
cardiff[playerid] = 0;
primesccar[playerid] = 0;
}
else SendClientMessage(playerid, COLOR_GREY, "You're too far away.");
}
else SendClientMessage(playerid, COLOR_GREY, "You already own a vehicle.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "The person offering the vehicle has disconnected.");
}
}
else if(primesccar[playerid] == 2)
{
if(IsPlayerConnectedEx(ofercar[playerid]))
{
if(playerVariables[playerid][pCarModel2] < 1)
{
if(IsPlayerInRangeOfPlayer(playerid, ofercar[playerid], 5.0))
{
GetVehiclePos(playerVariables[ofercar[playerid]][pCarID2], playerVariables[playerid][pCarPos2][0], playerVariables[playerid][pCarPos2][1], playerVariables[playerid][pCarPos2][2]);
GetVehicleZAngle(playerVariables[ofercar[playerid]][pCarID1], playerVariables[playerid][pCarPos2][3]);
playerVariables[playerid][pCarModel2] = playerVariables[ofercar[playerid]][pCarModel2]; // Transfer the car model
playerVariables[playerid][pCarColour2][0] = playerVariables[ofercar[playerid]][pCarColour2][0]; // And the colours, and paint job
playerVariables[playerid][pCarColour2][1] = playerVariables[ofercar[playerid]][pCarColour2][1];
playerVariables[playerid][pCarPaintjob2] = playerVariables[ofercar[playerid]][pCarPaintjob2];
playerVariables[playerid][pCarKM2] = playerVariables[ofercar[playerid]][pCarKM2];
while(x < 13)
{
playerVariables[playerid][pCarMods2][x] = GetVehicleComponentInSlot(playerVariables[ofercar[playerid]][pCarID2], x); // Mods, too.
x++;
}
x = 0;
playerVariables[playerid][pMoney] -= cardiff[playerid];
playerVariables[ofercar[playerid]][pMoney] += cardiff[playerid];
GetPlayerName(ofercar[playerid], giveCarPlayerName[1], MAX_PLAYER_NAME);
GetPlayerName(playerid, giveCarPlayerName[0], MAX_PLAYER_NAME);
format(giveCarString, sizeof(giveCarString), "%s has accepted your offer, and is now the owner of this %s.", giveCarPlayerName[0], VehicleNames[playerVariables[playerid][pCarModel2] - 400]);
SendClientMessage(ofercar[playerid], COLOR_WHITE, giveCarString);
format(giveCarString, sizeof(giveCarString), "You have accepted %s's offer, and are now the owner of this %s.", giveCarPlayerName[1], VehicleNames[playerVariables[playerid][pCarModel2] - 400]);
SendClientMessage(playerid, COLOR_WHITE, giveCarString);
new wakaname[25];
GetPlayerName(playerid,wakaname,25);
new str2[128];
format(str2,128,"UPDATE `playeraccounts` SET `playerCarModel2`='%d' WHERE `playerName`='%s'",playerVariables[playerid][pCarModel2],wakaname);
mysql_tquery(handle,str2);
new saveQuery[500];
format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarColour21 = '%d', playerCarColour22 = '%d', playerCarPosX2 = '%f', playerCarPosY2 = '%f', playerCarPosZ2 = '%f', playerCarPosZAngle2 = '%f' WHERE playerID = '%d'",playerVariables[playerid][pCarColour2][0],playerVariables[playerid][pCarColour2][1],
playerVariables[playerid][pCarPos2][0],playerVariables[playerid][pCarPos2][1],playerVariables[playerid][pCarPos2][2],playerVariables[playerid][pCarPos2][3], playerVariables[playerid][pInternalID]);
mysql_tquery(handle,saveQuery);
format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarPaintJob2 = '%d' WHERE playerID = '%d'",playerVariables[playerid][pCarPaintjob2],playerVariables[playerid][pInternalID]);
mysql_tquery(handle,saveQuery);
format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarKM2 = '%d' WHERE playerID = '%d'",playerVariables[playerid][pCarKM2],playerVariables[playerid][pInternalID]);
mysql_tquery(handle,saveQuery);
DestroyPlayerVehicle2(ofercar[playerid]);
SpawnPlayerVehicle(playerid);
ofercar[playerid] = -1;
cardiff[playerid] = 0;
primesccar[playerid] = 0;
//format(giveCarString2, sizeof(giveCarString2), "* %s has sold his %s to %s for %d$.", giveCarPlayerName[1], VehicleNames[playerVariables[playerid][pCarModel2]],giveCarPlayerName[0],cardiff[playerid]);
//submitToAdmins(giveCarString2,COLOR_RED);
}
else SendClientMessage(playerid, COLOR_GREY, "You're too far away.");
}
else SendClientMessage(playerid, COLOR_GREY, "You already own a vehicle.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "The person offering the vehicle has disconnected.");
}
}
else if(primesccar[playerid] == 3)
{
if(IsPlayerConnectedEx(ofercar[playerid]))
{
if(playerVariables[playerid][pCarModel3] < 1)
{
if(IsPlayerInRangeOfPlayer(playerid, ofercar[playerid], 5.0))
{
GetVehiclePos(playerVariables[ofercar[playerid]][pCarID3], playerVariables[playerid][pCarPos3][0], playerVariables[playerid][pCarPos3][1], playerVariables[playerid][pCarPos3][2]);
GetVehicleZAngle(playerVariables[ofercar[playerid]][pCarID3], playerVariables[playerid][pCarPos3][3]);
playerVariables[playerid][pCarModel3] = playerVariables[ofercar[playerid]][pCarModel3]; // Transfer the car model
playerVariables[playerid][pCarColour3][0] = playerVariables[ofercar[playerid]][pCarColour3][0]; // And the colours, and paint job
playerVariables[playerid][pCarColour3][1] = playerVariables[ofercar[playerid]][pCarColour3][1];
playerVariables[playerid][pCarPaintjob3] = playerVariables[ofercar[playerid]][pCarPaintjob3];
playerVariables[playerid][pCarKM3] = playerVariables[ofercar[playerid]][pCarKM3];
while(x < 13)
{
playerVariables[playerid][pCarMods3][x] = GetVehicleComponentInSlot(playerVariables[ofercar[playerid]][pCarID3], x); // Mods, too.
x++;
}
x = 0;
GetPlayerName(ofercar[playerid], giveCarPlayerName[1], MAX_PLAYER_NAME);
GetPlayerName(playerid, giveCarPlayerName[0], MAX_PLAYER_NAME);
playerVariables[playerid][pMoney] -= cardiff[playerid];
playerVariables[ofercar[playerid]][pMoney] += cardiff[playerid];
format(giveCarString, sizeof(giveCarString), "%s has accepted your offer, and is now the owner of this %s.", giveCarPlayerName[0], VehicleNames[playerVariables[playerid][pCarModel3] - 400]);
SendClientMessage(ofercar[playerid], COLOR_WHITE, giveCarString);
format(giveCarString, sizeof(giveCarString), "You have accepted %s's offer, and are now the owner of this %s.", giveCarPlayerName[1], VehicleNames[playerVariables[playerid][pCarModel3] - 400]);
SendClientMessage(playerid, COLOR_WHITE, giveCarString);
new wakaname[25];
GetPlayerName(playerid,wakaname,25);
new str2[128];
format(str2,128,"UPDATE `playeraccounts` SET `playerCarModel3`='%d' WHERE `playerName`='%s'",playerVariables[playerid][pCarModel3],wakaname);
mysql_tquery(handle,str2);
new saveQuery[500];
format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarColor31 = '%d', playerCarColour32 = '%d', playerCarPosX3 = '%f', playerCarPosY3 = '%f', playerCarPosZ3 = '%f', playerCarPosZAngle3 = '%f' WHERE playerName = '%d'",playerVariables[playerid][pCarColour3][0],playerVariables[playerid][pCarColour3][1],
playerVariables[playerid][pCarPos3][0],playerVariables[playerid][pCarPos3][1],playerVariables[playerid][pCarPos3][2],playerVariables[playerid][pCarPos3][3], wakaname);
mysql_tquery(handle,saveQuery);
DestroyPlayerVehicle3(ofercar[playerid]);
SpawnPlayerVehicle(playerid);
ofercar[playerid] = -1;
cardiff[playerid] = 0;
primesccar[playerid] = 0;
//format(giveCarString2, sizeof(giveCarString2), "* %s has sold his %s to %s for %d$.", giveCarPlayerName[1], VehicleNames[playerVariables[playerid][pCarModel3]],giveCarPlayerName[0],cardiff[playerid]);
//submitToAdmins(giveCarString2,COLOR_RED);
}
else SendClientMessage(playerid, COLOR_GREY, "You're too far away.");
}
else SendClientMessage(playerid, COLOR_GREY, "You already own a vehicle.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "The person offering the vehicle has disconnected.");
}
}
else if(primesccar[playerid] == 4)
{
if(IsPlayerConnectedEx(ofercar[playerid]))
{
if(playerVariables[playerid][pCarModel4] < 1)
{
if(IsPlayerInRangeOfPlayer(playerid, ofercar[playerid], 5.0))
{
GetVehiclePos(playerVariables[ofercar[playerid]][pCarID4], playerVariables[playerid][pCarPos4][0], playerVariables[playerid][pCarPos4][1], playerVariables[playerid][pCarPos4][2]);
GetVehicleZAngle(playerVariables[ofercar[playerid]][pCarID4], playerVariables[playerid][pCarPos4][3]);
playerVariables[playerid][pCarModel4] = playerVariables[ofercar[playerid]][pCarModel4]; // Transfer the car model
playerVariables[playerid][pCarColour4][0] = playerVariables[ofercar[playerid]][pCarColour4][0]; // And the colours, and paint job
playerVariables[playerid][pCarColour4][1] = playerVariables[ofercar[playerid]][pCarColour4][1];
playerVariables[playerid][pCarPaintjob4] = playerVariables[ofercar[playerid]][pCarPaintjob4];
playerVariables[playerid][pCarKM4] = playerVariables[ofercar[playerid]][pCarKM4];
while(x < 13)
{
playerVariables[playerid][pCarMods4][x] = GetVehicleComponentInSlot(playerVariables[ofercar[playerid]][pCarID4], x); // Mods, too.
x++;
}
x = 0;
playerVariables[playerid][pMoney] -= cardiff[playerid];
playerVariables[ofercar[playerid]][pMoney] += cardiff[playerid];
GetPlayerName(ofercar[playerid], giveCarPlayerName[1], MAX_PLAYER_NAME);
GetPlayerName(playerid, giveCarPlayerName[0], MAX_PLAYER_NAME);
format(giveCarString, sizeof(giveCarString), "%s has accepted your offer, and is now the owner of this %s.", giveCarPlayerName[0], VehicleNames[playerVariables[playerid][pCarModel4] - 400]);
SendClientMessage(ofercar[playerid], COLOR_WHITE, giveCarString);
format(giveCarString, sizeof(giveCarString), "You have accepted %s's offer, and are now the owner of this %s.", giveCarPlayerName[1], VehicleNames[playerVariables[playerid][pCarModel4] - 400]);
SendClientMessage(playerid, COLOR_WHITE, giveCarString);
new wakaname[25];
GetPlayerName(playerid,wakaname,25);
new str2[128];
format(str2,128,"UPDATE `playeraccounts` SET `playerCarModel4`='%d' WHERE `playerName`='%s'",playerVariables[playerid][pCarModel4],wakaname);
mysql_tquery(handle,str2);
new saveQuery[500];
format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarColor41 = '%d', playerCarColor42 = '%d', playerCarPosX4 = '%f', playerCarPosY4 = '%f', playerCarPosZ4 = '%f', playerCarPosZAngle4 = '%f' WHERE playerName = '%d'",playerVariables[playerid][pCarColour4][0],playerVariables[playerid][pCarColour4][1],
playerVariables[playerid][pCarPos4][0],playerVariables[playerid][pCarPos4][1],playerVariables[playerid][pCarPos4][2],playerVariables[playerid][pCarPos4][3], wakaname);
mysql_tquery(handle,saveQuery);
DestroyPlayerVehicle4(ofercar[playerid]);
SpawnPlayerVehicle(playerid);
ofercar[playerid] = -1;
cardiff[playerid] = 0;
primesccar[playerid] = 0;
//format(giveCarString2, sizeof(giveCarString2), "* %s has sold his %s to %s for %d$.", giveCarPlayerName[1], VehicleNames[playerVariables[playerid][pCarModel4]],giveCarPlayerName[0],cardiff[playerid]);
//submitToAdmins(giveCarString2,COLOR_RED);
}
else SendClientMessage(playerid, COLOR_GREY, "You're too far away.");
}
else SendClientMessage(playerid, COLOR_GREY, "You already own a vehicle.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "The person offering the vehicle has disconnected.");
}
}
else SendClientMessage(playerid, COLOR_GREY, "Nobody has offered you a vehicle.");
}