13.11.2009, 21:45
Code:
if(!strcmp(cmd,"/casa",true)){ new tmp[256]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)){ SendClientMessage(playerid, COLOR_RED, "/casa [preзo]"); return 1; } if(IsPlayerConnected(playerid)){ new Float:X, Float:Y, Float:Z, Float:A, str[256], File:temp; GetPlayerPos(playerid, X, Y, Z); GetPlayerFacingAngle(playerid, A); format(str,sizeof(str),"%f %f %f %f %d\r\n", X, Y, Z, A, strval(tmp)); temp = fopen("Casas/Coords.info", io_append); fwrite(temp, str); fclose(temp); CreatePickup(1273, 1, X, Y, Z); return 1; } if(strcmp(cmd, "/comprar", true) == 0) { new Float:X, Float:Y, Float:Z, Float:A; if(IsPlayerInAnyHouse(playerid)){ new h = GetPlayerHouseID(playerid); if(IsHouseSold(h)){ SendClientMessage(playerid, COLOR_RED, "Essa casa jб foi comprada."); return 1; } else { if(GetPlayerMoney(playerid) >= GetHousePrice(h)){ SendClientMessage(playerid, COLOR_JUIZ, "Casa comprada."); GivePlayerMoney(playerid, 0 - GetHousePrice(h)); GetHousePos(h, X, Y, Z, A); db_SetPlayerPos(PlayerName(playerid), X, Y, Z, A); SetHouseOwn(h, PlayerName(playerid)); SetHouseSold(h, 1); DestroyAllHousePickups(); LoadHousePickups(); return 1; } else { SendClientMessage(playerid, COLOR_RED, "Vocк nгo tem dinheiro suficiente para comprar essa casa."); return 1; } } } else { SendClientMessage(playerid, COLOR_RED, "Vocк nгo estб em uma casa."); return 1; } } } stock LoadHouses() { new File:temp; new index = 0; new tmp[256]; new Float:X, Float:Y, Float:Z, Float:A, Price; temp = fopen("Casas/Coords.info", io_readwrite); while(fread(temp, tmp, sizeof(tmp), false)) { index = 0; X = Float:floatstr(strtok(tmp, index)); Y = Float:floatstr(strtok(tmp, index)); Z = Float:floatstr(strtok(tmp, index)); A = Float:floatstr(strtok(tmp, index)); Price = strval(strtok(tmp, index)); CreateHouse(X, Y, Z, A, Price); } fclose(temp); }