23.06.2012, 22:22
I got problem, is this:
I sell prperty and in file:
Help
Код:
#include <a_samp>
#include <sscanf2>
#include <streamer>
#define SLOTS 500
#define MAX_PROPERTYS 500
#define FILE_PROPERTYS "Propertys/"
#define DIALOG_PROPERTY_OWNED 1
#define DIALOG_PROPERTY 2
#define RED 0xFF0000FF
#define GREEN 0x00FF00FF
#define C_ORANGE "{FF8000}"
#define C_DARK_ORANGE "{BB8000}"
enum PropertyMain
{
PropertyName[50],
PropertyFile[100],
PropertyIncome,
PropertyPrice,
PropertyOwned,
PropertyOwner[MAX_PLAYER_NAME],
Text3D:Property3DText,
Float:PropertyX,
Float:PropertyY,
Float:PropertyZ,
PropertyCheckpoint
}
new Property[MAX_PROPERTYS][PropertyMain];
enum PlayerMain
{
PlayerName[MAX_PLAYER_NAME],
PlayerMoney,
PlayerProperty[MAX_PROPERTYS],
PlayerPropertyPayment
}
new Player[SLOTS][PlayerMain];
public OnFilterScriptInit()
{
for(new P,A = MAX_PROPERTYS; P < A; P++)
{
format(Property[P][PropertyFile],100,"%s%d.ini",FILE_PROPERTYS,P);
if(fexist(Property[P][PropertyFile]))
{
new File:File = fopen(Property[P][PropertyFile],io_read);
new String[250];
fread(File,String);
sscanf(String,"s[50] i i i s[24] f f f",Property[P][PropertyName],Property[P][PropertyIncome],Property[P][PropertyPrice],Property[P][PropertyOwned],Property[P][PropertyOwner],Property[P][PropertyX],Property[P][PropertyY],Property[P][PropertyZ]);
if(Property[P][PropertyOwned] == 1)
{
Property[P][PropertyCheckpoint] = CreateDynamicCP(Property[P][PropertyX],Property[P][PropertyY],Property[P][PropertyZ],5.0000);
format(String,250,"====================\nPosiadłość Zajęta\n====================\n%s\nWłaściciel: %s\nDochуd: %d",Property[P][PropertyName],Property[P][PropertyOwner],Property[P][PropertyIncome]);
Property[P][Property3DText] = CreateDynamic3DTextLabel(String,RED,Property[P][PropertyX],Property[P][PropertyY],Property[P][PropertyZ],20.0000);
}
if(Property[P][PropertyOwned] == 0)
{
Property[P][PropertyCheckpoint] = CreateDynamicCP(Property[P][PropertyX],Property[P][PropertyY],Property[P][PropertyZ],5.0000);
format(String,250,"====================\nPosiadłość Wolna\n====================\n%s\nDochуd: %d\nKoszt: %d",Property[P][PropertyName],Property[P][PropertyIncome],Property[P][PropertyPrice]);
Property[P][Property3DText] = CreateDynamic3DTextLabel(String,GREEN,Property[P][PropertyX],Property[P][PropertyY],Property[P][PropertyZ],20.0000);
}
}
}
return 1;
}
public OnFilterScriptExit()
{
for(new P,A = MAX_PROPERTYS; P < A; P++)
{
DestroyDynamicCP(Property[P][PropertyCheckpoint]);
}
return 1;
}
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid,Player[playerid][PlayerName],MAX_PLAYER_NAME);
Player[playerid][PlayerMoney] = 0;
Player[playerid][PlayerProperty] = -1;
for(new P,A = MAX_PROPERTYS; P < A; P++)
{
if(Property[P][PropertyOwned] == 1)
{
if(!strcmp(Player[playerid][PlayerName],Property[P][PropertyOwner],false))
{
Player[playerid][PlayerProperty] = P;
Player[playerid][PlayerPropertyPayment] = SetTimerEx("OnPlayerPropertyPeyment",300000,1,"i",playerid);
break;
}
}
}
return 1;
}
public OnPlayerDisconnect(playerid,reason)
{
if(Player[playerid][PlayerProperty] != -1)
{
KillTimer(Player[playerid][PlayerPropertyPayment]);
}
return 1;
}
public OnPlayerEnterDynamicCP(playerid)
{
new String[250];
for(new P = 0; P < MAX_PROPERTYS; P++)
{
if(IsPlayerInDynamicCP(playerid,Property[P][PropertyCheckpoint]))
{
if(Property[P][PropertyOwned] == 1)
{
if(!strcmp(Player[playerid][PlayerName],Property[P][PropertyOwner],false))
{
format(String,250,""C_ORANGE"Czy na pewno chcesz sprzedać swoją posiadłość?\n"C_ORANGE"Nazwa twojej posiadlości to "C_DARK_ORANGE"%s"C_ORANGE".\n"C_ORANGE"Jej dochуd wynosi "C_DARK_ORANGE"%d "C_ORANGE"pieniędzy, możesz ją sprzedać za "C_DARK_ORANGE"%d "C_ORANGE"pieniędzy.",Property[P][PropertyName],Property[P][PropertyIncome],Property[P][PropertyPrice]);
ShowPlayerDialog(playerid,DIALOG_PROPERTY_OWNED,DIALOG_STYLE_MSGBOX,""C_ORANGE"Sprzedaj Posiadłość",String,"Ok","Anuluj");
break;
}
}
if(Property[P][PropertyOwned] == 0)
{
format(String,250,""C_ORANGE"Czy na pewno chcesz kupić tą posiadłość?\n"C_ORANGE"Nazwa tej posiadlości to "C_DARK_ORANGE"%s"C_ORANGE".\n"C_ORANGE"Jej dochуd wynosi "C_DARK_ORANGE"%d "C_ORANGE"pieniedzy, możesz ją kupić za "C_DARK_ORANGE"%d "C_ORANGE"pieniędzy.",Property[P][PropertyName],Property[P][PropertyIncome],Property[P][PropertyPrice]);
ShowPlayerDialog(playerid,DIALOG_PROPERTY,DIALOG_STYLE_MSGBOX,"Kup Posiadłość",String,"Ok","Anuluj");
break;
}
}
}
return 1;
}
public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
{
new String[250];
if(dialogid == DIALOG_PROPERTY_OWNED)
{
if(response)
{
KillTimer(Player[playerid][PlayerPropertyPayment]);
new PropertyID = Player[playerid][PlayerProperty];
format(String,250,"====================\nPosiadłość Wolna\n====================\n%s\nDochуd: %d\nKoszt: %d",Property[PropertyID][PropertyName],Property[PropertyID][PropertyIncome],Property[PropertyID][PropertyPrice]);
UpdateDynamic3DTextLabelText(Property[PropertyID][Property3DText],GREEN,String);
format(Property[PropertyID][PropertyFile],100,"%s%d.ini",FILE_PROPERTYS,PropertyID);
fremove(Property[PropertyID][PropertyFile]);
new File:File = fopen(Property[PropertyID][PropertyFile],io_append);
format(String,250,"%s %i %i %i None %f %f %f",Property[PropertyID][PropertyName],Property[PropertyID][PropertyIncome],Property[PropertyID][PropertyPrice],Property[PropertyID][PropertyOwned],Property[PropertyID][PropertyX],Property[PropertyID][PropertyY],Property[PropertyID][PropertyZ]);
Player[playerid][PlayerMoney] += Property[PropertyID][PropertyPrice];
Player[playerid][PlayerProperty] = -1;
fwrite(File,String);
fclose(File);
}
}
return 1;
}
Quote:
|
Posiadlość 100 100 1 N7D4 123.5628 -80.4573 1.5781PosiadloВśĂ¦ 100 100 1 None 123.562797 -80.457298 1.578099 |

