07.11.2013, 15:48
Hey, I got trouble with this cmd, the player should be able to buy the nearest service if it's not owned by someone else yet, if the service ID is 0 the command works perfectly fine, but anything above that I get the message 'You aren't near a service thats for sale' everytime I type this command near a service thats for sale. What could cause this problem?
pawn Код:
CMD:buyservice(playerid, params[])
{
new playername[MAX_PLAYER_NAME];
for(new x = 0; x < sizeof(ServiceInfo); x++)
{
if(IsPlayerInRangeOfPoint(playerid,4.0,ServiceInfo[x][sExteriorX],ServiceInfo[x][sExteriorY],ServiceInfo[x][sExteriorZ]))
{
if(ServiceInfo[x][sOwned] == 0)
{
if(PlayerInfo[playerid][pServiceOwner] >= 0) return SendClientMessage(playerid, COLOR_DARKRED, "[SERVER] {FFFFFF}You already own a service.");
if(GetPlayerCash(playerid) < ServiceInfo[x][sPrice]) return SendClientMessage(playerid, COLOR_DARKRED, "[SERVER] {FFFFFF}You can't afford this service.");
ServiceInfo[x][sOwned] = 1;
PlayerInfo[playerid][pServiceOwner] = x;
PlayerInfo[playerid][pService] = x;
PlayerInfo[playerid][pSRank] = 6;
GivePlayerCash(playerid,-ServiceInfo[x][sPrice]);
GetPlayerName(playerid,playername, sizeof(playername));
strmid(ServiceInfo[x][sOwner],playername,0,strlen(playername),255);
SendClientMessage(playerid,COLOR_WHITE,"Congratulations on your purchase, contact a admin to set your service.");
UpdateService(x);
return 1;
}
else return SendClientMessage(playerid, COLOR_DARKRED, "[SERVER] {FFFFFF}This service isn't for sale.");
}
else return SendClientMessage(playerid, COLOR_DARKRED, "[SERVER] {FFFFFF}You aren't near any service thats for sale.");
}
return 1;
}