26.11.2017, 08:52

pawn Код:
CMD:buyspawn(playerid, params[])
{
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_RED, "You need to login before use command.");
for(new i = 0; i < MAX_PICKUP; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1, pPickInfo[i][dXe], pPickInfo[i][dYe], pPickInfo[i][dZe]))
{
if(PlayerInfo[playerid][pMoney] < 100) return SendClientMessage(playerid, COLOR_BLUE2, "You need $100 for this.");
if(pPickInfo[i][dMi] == 1)
{
if(PlayerInfo[playerid][pTeamFaction] == 1 )
{
PlayerInfo[playerid][pMoney] -= 100;
SetSpawnInfo(playerid, gTeam[playerid], gSkin[playerid], pPickInfo[i][dXe], pPickInfo[i][dYe], pPickInfo[i][dZe], pPickInfo[i][dAe], -1, -1, -1, -1, -1, -1);
new str[196];
format(str, sizeof(str), "UPDATE `playeraccounts` SET pSpawnPosX='%0.2f', pSpawnPosY='%0.2f', pSpawnPosZ='%0.2f', pSpawnPosFacing='%0.2f', pSpawnSaved='1', pMoney='%d' WHERE pID='%d'", pPickInfo[i][dXe], pPickInfo[i][dYe], pPickInfo[i][dZe], pPickInfo[i][dAe], PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pID]);
mysql_query(Connection, str);
PlayerInfo[playerid][pSpawnPosX] = pPickInfo[i][dXe];
PlayerInfo[playerid][pSpawnPosY] = pPickInfo[i][dYe];
PlayerInfo[playerid][pSpawnPosZ] = pPickInfo[i][dZe];
PlayerInfo[playerid][pSpawnPosFacing] = pPickInfo[i][dAe];
PlayerInfo[playerid][pSpawnSaved] = 1;
new query[100];
mysql_format(Connection, query, sizeof(query), "SELECT * FROM `playeraccounts` WHERE `Username` = '%e' LIMIT 1", pName(playerid));
mysql_query(Connection, query);
PlayerInfo[playerid][pMoney] = cache_get_field_content_int(0, "pMoney");
a_SetPlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
}
else
{
SendClientMessage(playerid, COLOR_BLUE2, "You are in the wrong team for this spawn.");
}
}
if(pPickInfo[i][dMi] == 2)
{
if(PlayerInfo[playerid][pTeamFaction] == 2)
{
PlayerInfo[playerid][pMoney] -= 100;
SetSpawnInfo(playerid, gTeam[playerid], gSkin[playerid], pPickInfo[i][dXe], pPickInfo[i][dYe], pPickInfo[i][dZe], pPickInfo[i][dAe], -1, -1, -1, -1, -1, -1);
new str[196];
format(str, sizeof(str), "UPDATE `playeraccounts` SET pSpawnPosX='%0.2f', pSpawnPosY='%0.2f', pSpawnPosZ='%0.2f', pSpawnPosFacing='%0.2f', pSpawnSaved='1', pMoney='%d' WHERE pID='%d'", pPickInfo[i][dXe], pPickInfo[i][dYe], pPickInfo[i][dZe], pPickInfo[i][dAe], PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pID]);
mysql_query(Connection, str);
PlayerInfo[playerid][pSpawnPosX] = pPickInfo[i][dXe];
PlayerInfo[playerid][pSpawnPosY] = pPickInfo[i][dYe];
PlayerInfo[playerid][pSpawnPosZ] = pPickInfo[i][dZe];
PlayerInfo[playerid][pSpawnPosFacing] = pPickInfo[i][dAe];
PlayerInfo[playerid][pSpawnSaved] = 1;
new query[100];
mysql_format(Connection, query, sizeof(query), "SELECT * FROM `playeraccounts` WHERE `Username` = '%e' LIMIT 1", pName(playerid));
mysql_query(Connection, query);
PlayerInfo[playerid][pMoney] = cache_get_field_content_int(0, "pMoney");
a_SetPlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
}
else
{
SendClientMessage(playerid, COLOR_BLUE2, "You are in the wrong team for this spawn.");
}
}
}
else
{
SendClientMessage(playerid, COLOR_BLUE2, "You are too far from spawn points.");
}
}
return 1;
}