24.02.2019, 19:09
Bump. Anyone?
CMD:creategarage(playerid, params[])
{
if(Player[playerid][AdminLevel] < 5) return 0;
new price, size;
if(sscanf(params, "dd(0)", price, size))
{
SCM(playerid, COLOR_BELGREEN, "» [USAGE]: /creategarage [price] [size(default 0)]");
return SCM(playerid, COLOR_BELGREEN, "» Size: 0 - Small Garage , 1 - Medium Garage, 2 - Big Garage.");
}
if((size < 0) || (size > 2)) return SCM(playerid, COLOR_ERROR, "» Size must be from 0 to 2.");
if((price < 1) || (price > 999999)) return SCM(playerid, COLOR_ERROR, "» Invalid price.");
for(new i = 1; i < MAX_GARAGES; i++)
{
if(!GarageInfo[i][garageExists])
{
GarageInfo[i][garageID] = i;
new query[300];
mysql_format(g_SQL, query, sizeof query, "INSERT INTO `garages` (`garagePrice`, `garageSize`) VALUES ('%d', '%d')", price, size);
mysql_tquery(g_SQL, query, "OnGarageCreated", "d", i);
GarageInfo[i][garageExists] = true;
GetPlayerPos(playerid, GarageInfo[i][garagePos][0], GarageInfo[i][garagePos][1], GarageInfo[i][garagePos][2]);
GetPlayerFacingAngle(playerid, GarageInfo[i][garagePos][3]);
GarageInfo[i][garagePos][0] = GarageInfo[i][garagePos][0] + (1.5 * floatsin(-GarageInfo[i][garagePos][3], degrees));
GarageInfo[i][garagePos][1] = GarageInfo[i][garagePos][1] + (1.5 * floatcos(-GarageInfo[i][garagePos][3], degrees));
GarageInfo[i][garageVW] = GetPlayerVirtualWorld(playerid);
GarageInfo[i][garagePrice] = price;
GarageInfo[i][garageSize] = size;
RefreshGarage(i);
SCMEX(playerid, COLOR_YELLOW, "» You have successfully created a garage. ID: %d - Price: %s - Size: %d", i, formatInt(price), size);
printf("Garage is saved for i: %d", i);
if(i == -1) return SCM(playerid, COLOR_ERROR, "» The server has reached the limit for garages.");
return 1;
}
}
}
function OnQueryFinished(extraid, threadid)
{
switch(threadid)
{
case THREAD_CREATE_GARAGE:
{
GarageInfo[extraid][garageID] = extraid;
SaveGarage(extraid);
}
}
return 1;
}
mysql_tquery(g_SQL, query, "OnGarageCreated", "d", GarageInfo();
CMD:creategarage(playerid, params[])
{
if(Player[playerid][AdminLevel] < 5) return 0;
new price, size;
if(sscanf(params, "dd(0)", price, size))
{
SCM(playerid, COLOR_BELGREEN, "» [USAGE]: /creategarage [price] [size(default 0)]");
return SCM(playerid, COLOR_BELGREEN, "» Size: 0 - Small Garage , 1 - Medium Garage, 2 - Big Garage.");
}
if((size < 0) || (size > 2)) return SCM(playerid, COLOR_ERROR, "» Size must be from 0 to 2.");
if((price < 1) || (price > 999999)) return SCM(playerid, COLOR_ERROR, "» Invalid price.");
for(new i = 1; i < MAX_GARAGES; i++)
{
if(!GarageInfo[i][garageExists])
{
GarageInfo[i][garageID] = i;
new query[300];
mysql_format(g_SQL, query, sizeof query, "INSERT INTO `garages` (`garagePrice`, `garageSize`) VALUES ('%d', '%d')", price, size);
mysql_tquery(g_SQL, query, "OnQueryFinished", "dd", id, THREAD_CREATE_GARAGE);
GarageInfo[i][garageExists] = true;
GetPlayerPos(playerid, GarageInfo[i][garagePos][0], GarageInfo[i][garagePos][1], GarageInfo[i][garagePos][2]);
GetPlayerFacingAngle(playerid, GarageInfo[i][garagePos][3]);
GarageInfo[i][garagePos][0] = GarageInfo[i][garagePos][0] + (1.5 * floatsin(-GarageInfo[i][garagePos][3], degrees));
GarageInfo[i][garagePos][1] = GarageInfo[i][garagePos][1] + (1.5 * floatcos(-GarageInfo[i][garagePos][3], degrees));
GarageInfo[i][garageVW] = GetPlayerVirtualWorld(playerid);
GarageInfo[i][garagePrice] = price;
GarageInfo[i][garageSize] = size;
RefreshGarage(i);
SCMEX(playerid, COLOR_YELLOW, "» You have successfully created a garage. ID: %d - Price: %s - Size: %d", i, formatInt(price), size);
printf("Garage is saved for i: %d", i);
if(i == -1) return SCM(playerid, COLOR_ERROR, "» The server has reached the limit for garages.");
return 1;
}
}
}
CMD:buygarage(playerid, params[])
{
new id = GetNearestGarage(playerid);
if(id == -1) return SCM(playerid, COLOR_ERROR, "» There are no garages near you.");
if(GarageInfo[id][garageOwnerID] == Player[playerid][ID]) return SCM(playerid, COLOR_ERROR, "» This garage is already yours.");
if(GarageInfo[id][garageOwned]) return SCM(playerid, COLOR_ERROR, "» This garage has been already bought.");
if(GetPlayerMoney(playerid) < GarageInfo[id][garagePrice])
return SCMEX(playerid, COLOR_ERROR, "» You can't afford to buy this garage. You need %s.", formatInt(GarageInfo[id][garagePrice]));
SCMEX(playerid, COLOR_YELLOW, "» [GARAGE] You've bought this garage for %s!", formatInt(GarageInfo[id][garagePrice]));
SCM(playerid, COLOR_YELLOW, "» [GARAGE] Garage keys and ownership have been transferred to you.");
GivePlayerMoney(playerid, -GarageInfo[id][garagePrice]);
GarageInfo[id][garageOwned] = 1;
GarageInfo[id][garagePrice] = 0;
GarageInfo[id][garagePlayerSellPrice] = 0;
GarageInfo[id][garageOwnerID] = Player[playerid][ID];
RefreshGarage(id);
SaveGarage(id);
GameTextForPlayer(playerid, "~w~Garage ~g~bought~w~!", 3000, 3);
return 1;
}
[15:01:59] [DEBUG] mysql_query(1, "UPDATE `garages` SET `garageOwnerID` = '1', `garageOwned` = '1', `garagePrice` = '0', `garagePlayerSellPrice` = '0', `garageSize` = '2', `garageCustomName` = 'e' WHERE `garageID` = '0'", 1) (C:\test\gamemodes\server.pwn:2602 -> C:\test\gamemodes\server.pwn:6480) [15:01:59] [DEBUG] CHandle::Execute(this=0x23df80, type=3, query=0x2a932 [15:01:59] [DEBUG] CConnection::Execute(query=0x2a9328, this=0x23f4d8, connection=0x2007f0) [15:01:59] [DEBUG] CQuery::Execute(this=0x2a9328, connection=0x2007f0) [15:01:59] [INFO] query "UPDATE `garages` SET `garageOwnerID` = '1', `garageOwned` = '1', `garagePrice` = '0', `garagePlayerSellPrice` = '0', `garageSize` = '2', `garageCustomName` = 'e' WHERE `garageID` = '0'" successfully executed within 0.800 milliseconds [15:01:59] [DEBUG] CResultSet::Create(connection=0x2007f0, query_str='UPDATE `garages` SET `garageOwnerID` = '1', `garageOwned` = '1', `garagePrice` = '0', `garagePlayerSellPrice` = '0', `garageSize` = '2', `garageCustomName` = 'e' WHERE `garageID` = '0'') |
new query[300];
mysql_format(g_SQL, query, sizeof query, "UPDATE `garages` SET `garageOwned` = 1, `garagePrice` = 0, `garagePlayerSellPrice` = 0, `garageOwnerID` = '%d'",
Player[playerid][ID]);
mysql_tquery(g_SQL, query, "OnQueryFinished", "dd", id, THREAD_SAVE_GARAGE);