09.04.2011, 14:03
Im having this little problem, that when he enters the dynamic cp it shows the dialog, then when there is a response
or better saying, when he presses "Buy", the dialogresponse isn't called, nothing happenes when there is a response. Why?
or better saying, when he presses "Buy", the dialogresponse isn't called, nothing happenes when there is a response. Why?
pawn Код:
public OnPlayerEnterDynamicCP(playerid,checkpointid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
for(new i = -1; i < MAX_HOUSES; i++)
{
if(checkpointid == Checkpoint[i])
{
if(HInfo[i][owned] == 0)
{
new string[200];
format(string,sizeof(string),"This house is up for sale for $%i",HInfo[i][price]);
ShowPlayerDialog(playerid,2650,0,"Buy house",string,"Buy","Cancel");
SetPVarInt(playerid,"InHouseID",i);
break;
}
else if(strcmp(HInfo[i][owner],pName,true) == 1)
{
SetPlayerInterior(playerid,HInfo[i][interior]);
SetPlayerVirtualWorld(playerid,HInfo[i][world]);
SetPlayerPos(playerid,HInfo[i][telex],HInfo[i][teley],HInfo[i][telez]);
break;
}
}
}
}
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 2650)
{
if(response)
{
new pName[MAX_PLAYER_NAME],file[200],string[200];
if(GetPlayerMoney(playerid) < HInfo[GetPVarInt(playerid,"InHouseID")][price]) return SendClientMessage(playerid,red,"You dont have enough cash for this house");
HInfo[GetPVarInt(playerid,"InHouseID")][owned] = 1;
format(file,sizeof(file),"FHouse/houses/%i.ini",GetPVarInt(playerid,"InHouseID"));
GetPlayerName(playerid,pName,sizeof(pName));
strmid(HInfo[GetPVarInt(playerid,"InHouseID")][owner],pName,0,strlen(pName),255);
SetPlayerInterior(playerid,HInfo[GetPVarInt(playerid,"InHouseID")][interior]);
SetPlayerVirtualWorld(playerid,HInfo[GetPVarInt(playerid,"InHouseID")][world]);
SetPlayerPos(playerid,HInfo[GetPVarInt(playerid,"InHouseID")][telex],HInfo[GetPVarInt(playerid,"InHouseID")][teley],HInfo[GetPVarInt(playerid,"InHouseID")][telez]);
GivePlayerMoney(playerid,-HInfo[GetPVarInt(playerid,"InHouseID")][price]);
INI_Open(file);
HInfo[GetPVarInt(playerid,"InHouseID")][owned] = 1;
INI_WriteInt("Owned",1);
INI_WriteString("Owner",HInfo[GetPVarInt(playerid,"InHouseID")][owner]);
INI_Save();
INI_Close();
format(string,sizeof(string),"Owned by: %s \nHouse cost: %i \nID: %i",pName,HInfo[GetPVarInt(playerid,"InHouseID")][price],GetPVarInt(playerid,"InHouseID"));
Update3DTextLabelText(HInfo[GetPVarInt(playerid,"InHouseID")][label],0x00FF40FF,string);
print("readed!");
return 1;
}
}
return 0;
}