08.09.2012, 13:47
This cmd crash pawno when i complie can you guys see the problem?
pawn Код:
}
//===============================[House system]=================================================
if(strcmp(cmd,"/house",true)==0)
{
if(IsPlayerConnected(playerid))
{
new x_nr[128];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr))
{
SendClientMessage(playerid, COLOR_WHITE, "HINT: /house [name]");
SendClientMessage(playerid, COLOR_WHITE, "Available names: info, putgun, takegun, putarmour, takearmour, putweed, takeweed, putmats, takemats");
return 1;
}
if(strcmp(x_nr,"buy",true) == 0)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
for(new h = 0; h < sizeof(HouseInfo); h++)
{
if(PlayerToPoint(2.0, playerid, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]) && HouseInfo[h][hOwned] == 0)
{
if(PlayerInfo[playerid][pLevel] < HouseInfo[h][hLevel])
{
format(string, sizeof(string), " You must be Level %d to purchase this !", HouseInfo[h][hLevel]);
SendClientMessage(playerid, COLOR_GRAD5, string);
return 1;
}
if(PlayerInfo[playerid][pHousekey] != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHousekey]][hOwner], true) == 0)
{
SendClientMessage(playerid, COLOR_WHITE, " You already own a house, type /sellhouse if you want to buy this one !");
return 1;
}
if(GetPlayerPCash(playerid) >= HouseInfo[h][hValue])
{
PlayerInfo[playerid][pHousekey] = h;
HouseInfo[h][hOwned] = 1;
HouseEntered[playerid] = h;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(HouseInfo[h][hOwner], sendername, 0, strlen(sendername), 255);
GivePlayerPCash(playerid,-HouseInfo[h][hValue]);
//PlayerPlayMusic(playerid);
SetPlayerInterior(playerid,HouseInfo[h][hInt]);
SetPlayerVirtualWorld(playerid,h+100);
DOO_SetPlayerPos(playerid,HouseInfo[h][hExitx],HouseInfo[h][hExity],HouseInfo[h][hExitz]);
GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and typing /exit", 5000, 3);
PlayerInfo[playerid][pInt] = HouseInfo[h][hInt];
PlayerInfo[playerid][pLocal] = h;
DestroyPickup(HouseInfo[h][hPickupID]);
HouseInfo[h][hPickupID]=CreatePickup(1272, 1, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]);
SendClientMessage(playerid, COLOR_WHITE, "Congratulations, on your new Purchase !");
SendClientMessage(playerid, COLOR_WHITE, "Type /help to review the new property help section !");
OnPropUpdate();
HouseEntered[playerid] = h;
OnPlayerDataSave(playerid);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You don't have the cash for that");
return 1;
}
}
}
if(strcmp(x_nr,"rent",true) == 0)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
for(new h = 0; h < sizeof(HouseInfo); h++)
{
if(PlayerToPoint(2.0, playerid, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]) && HouseInfo[h][hOwned] == 1 && HouseInfo[h][hRentabil] == 1)
{
if(PlayerInfo[playerid][pHousekey] != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHousekey]][hOwner], true) == 0)
{
SendClientMessage(playerid, COLOR_WHITE, " You already own a house, type /house unrent if you want to rent this one.");
return 1;
}
if(strcmp(playername, HouseInfo[h][hOwner], true) == 0)
{
SendClientMessage(playerid, COLOR_WHITE, " You already own a house.");
return 1;
}
if(GetPlayerPCash(playerid) >= HouseInfo[h][hRent])
{
PlayerInfo[playerid][pHousekey] = h;
HouseEntered[playerid] = h;
GivePlayerPCash(playerid,-HouseInfo[h][hRent]);
if(PlayerInfo[playerid][pLevel] >= 2)
{
HouseInfo[h][hTakings] = HouseInfo[h][hTakings]+HouseInfo[h][hRent];
}
//PlayerPlayMusic(playerid);
SetPlayerInterior(playerid,HouseInfo[h][hInt]);
SetPlayerVirtualWorld(playerid,h+100);
DOO_SetPlayerPos(playerid,HouseInfo[h][hExitx],HouseInfo[h][hExity],HouseInfo[h][hExitz]);
GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and typing /exit", 5000, 3);
PlayerInfo[playerid][pInt] = HouseInfo[h][hInt];
PlayerInfo[playerid][pLocal] = h;
SendClientMessage(playerid, COLOR_WHITE, "Congratulations, You can enter and exit here anytime.");
SendClientMessage(playerid, COLOR_WHITE, "Type /help to review the new property help section.");
OnPlayerDataSave(playerid);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You don't have the cash for that");
return 1;
}
}
}
}
if(strcmp(x_nr,"sell",true) == 0)
{
GetPlayerName(playerid, playername, sizeof(playername));
if(PlayerInfo[playerid][pHousekey] != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHousekey]][hOwner], true) == 0)
{
SendClientMessage(playerid, COLOR_WHITE, " You own this house !");
return 1;
}
PlayerInfo[playerid][pHousekey] = 255;
SendClientMessage(playerid, COLOR_WHITE, "You are now homeless.");
return 1;
}
else if(strcmp(x_nr,"repair",true) == 0)
{
GetPlayerName(playerid, playername, sizeof(playername));
if(PlayerInfo[playerid][pHousekey] == 255)
{
SendClientMessage(playerid, COLOR_WHITE, "You don't own a house.");
return 1;
}
if(PlayerInfo[playerid][pHousekey] != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHousekey]][hOwner], true) == 0)
{
new house = PlayerInfo[playerid][pHousekey];
RemoveAllFurn(house);
HouseInfo[house][hHel] = 0;
HouseInfo[house][hArm] = 0;
HouseInfo[house][hHealthx] = 0;
HouseInfo[house][hHealthy] = 0;
HouseInfo[house][hHealthz] = 0;
HouseInfo[house][hArmourx] = 0;
HouseInfo[house][hArmoury] = 0;
HouseInfo[house][hArmourz] = 0;
HouseInfo[house][hLock] = 1;
HouseInfo[house][hOwned] = 0;
HouseInfo[house][hVec] = 418;
HouseInfo[house][hVcol1] = -1;
HouseInfo[house][hVcol2] = -1;
SafeInfo[house][sDrugs] = 0;
SafeInfo[house][sMats] = 0;
SafeInfo[house][sGun][0] = 0;
SafeInfo[house][sGun][1] = 0;
SafeInfo[house][sGun][2] = 0;
SafeInfo[house][sGun][3] = 0;
SafeInfo[house][sAmmo][0] = 0;
SafeInfo[house][sAmmo][1] = 0;
SafeInfo[house][sAmmo][2] = 0;
SafeInfo[house][sAmmo][3] = 0;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(HouseInfo[house][hOwner], "The State", 0, strlen("The State"), 255);
GivePlayerPCash(playerid,HouseInfo[house][hValue]);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
format(string, sizeof(string), "~w~Congratulations~n~ You have sold your property for ~n~~g~$%d", HouseInfo[house][hValue]);
GameTextForPlayer(playerid, string, 10000, 3);
PlayerInfo[playerid][pHousekey] = 255;
DestroyPickup(HouseInfo[house][hPickupID]);
HouseInfo[house][hPickupID]=CreatePickup(1273, 1, HouseInfo[house][hEntrancex], HouseInfo[house][hEntrancey], HouseInfo[house][hEntrancez]);
if(PlayerInfo[playerid][pLocal] == house)
{
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid,0);
DOO_SetPlayerPos(playerid,HouseInfo[house][hEntrancex],HouseInfo[house][hEntrancey],HouseInfo[house][hEntrancez]);
PlayerInfo[playerid][pInt] = 0;
}
OnPropUpdate();
SaveSafe();
OnPlayerDataSave(playerid);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You don't own a house.");
return 1;
}
}
else if(strcmp(x_nr,"setrent",true) == 0)
{
new bouse = PlayerInfo[playerid][pHousekey];
GetPlayerName(playerid, playername, sizeof(playername));
if (bouse != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHousekey]][hOwner], true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setrent [RentFee]");
return 1;
}
if(strval(tmp) < 1 || strval(tmp) > 500)
{
SendClientMessage(playerid, COLOR_WHITE, "Minimum rent is $1, Maximum rent is $500.");
return 1;
}
HouseInfo[bouse][hRent] = strval(tmp);
OnPropUpdate();
format(string, sizeof(string), "House rent set to $%d", HouseInfo[bouse][hRent]);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " You don't own a house");
return 1;
}
}
else if(strcmp(x_nr,"evictall",true) == 0)
{
new bouse = PlayerInfo[playerid][pHousekey];
if (bouse != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHousekey]][hOwner], true) == 0)
{
foreach (Player, i)
{
if(gPlayerLogged[i] == 1)
{
if(i != playerid)
{
if (PlayerInfo[i][pHousekey] == PlayerInfo[playerid][pHousekey] )
{
SendClientMessage(i, COLOR_WHITE, "You have been evicted from your house.");
PlayerInfo[i][pHousekey] = 255;
}
}
}
}
SendClientMessage(playerid, COLOR_WHITE, "Everyone have been evicted.");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " You don't own a house !");
return 1;
}
}
else if(strcmp(x_nr,"evict",true) == 0)
{
new bouse = PlayerInfo[playerid][pHousekey];
GetPlayerName(playerid, playername, sizeof(playername));
if (bouse != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHousekey]][hOwner], true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /evict [playerid/PartOfName]");
}
new target;
//target = strval(tmp);
target = ReturnUser(tmp);
if (target == playerid)
{
SendClientMessage(target, COLOR_WHITE, "You cant evict yourself.");
return 1;
}
if(IsPlayerConnected(target))
{
if(target != INVALID_PLAYER_ID)
{
if(PlayerInfo[target][pHousekey] == PlayerInfo[playerid][pHousekey])
{
SendClientMessage(target, COLOR_WHITE, "You have been evicted");
SendClientMessage(playerid, COLOR_WHITE, "Player has been evicted");
PlayerInfo[target][pHousekey] = 255;
return 1;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "Player doesn't rent at your House !");
return 1;
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " You don't own a house !");
return 1;
}
}
else if(strcmp(x_nr,"shake",true) == 0)
{
if(ShakeOffer[playerid] < SCRIPT_PLAYERS)
{
if(IsPlayerConnected(ShakeOffer[playerid]))
{
GetPlayerName(ShakeOffer[playerid], giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* You have accepted the handshake.");
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s has accepted your handshake offer.",sendername);
ApplyAnimationEx(playerid,"GANGS","hndshkfa_swt",4.0,0,0,0,0,0);
ApplyAnimationEx(ShakeOffer[playerid],"GANGS","hndshkfa_swt",4.0,0,0,0,0,0);
SendClientMessage(ShakeOffer[playerid], COLOR_LIGHTBLUE, string);
ShakeOffer[playerid] = SCRIPT_PLAYERS;
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " No-one has offered a handshake...");
return 1;
}
}
}
else if(strcmp(x_nr,"setrentable",true) == 0)
{
new bouse = PlayerInfo[playerid][pHousekey];
GetPlayerName(playerid, playername, sizeof(playername));
if (bouse != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHousekey]][hOwner], true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setrentable [0/1]");
}
if(strval(tmp) < 0 || strval(tmp) > 2)
{
SendClientMessage(playerid, COLOR_GRAD1, "Dont go below 0, or above 2 at once.");
return 1;
}
HouseInfo[bouse][hRentabil] = strval(tmp);
OnPropUpdate();
format(string, sizeof(string), "House rentable set to %d.", HouseInfo[bouse][hRentabil]);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " You don't own a house !");
return 1;
}
}
else { return 1; }
}
return 1;