if(dialogid == BUY_HOUSE && response==1)
{
switch(listitem)
{
case 0:
{
new id = 0, name[25], count = 0;
if( count >= 3 )
return SendClientMessage(playerid, RED, "ERROR:{FFFFFF} You can't own more than 3 houses at a time");
if( GetPlayerMoney(playerid) < hInfo[id][Price] )
return SendClientMessage(playerid, RED, "ERROR:{FFFFFF} You do not have enough money to buy this house");
for(new i=1; i<=CreatedHouses; i++)
{
id = i;
break;
}
for(new i=1; i<=CreatedHouses; i++)
{
GetPlayerName(playerid, name, sizeof(name));
if(strcmp(name, hInfo[i][Owner]) == 0)
{
count++;
}
}
//count++;
GetPlayerName(playerid, name, 25);
hInfo[id][Owned] = 1;
hInfo[id][Owner] = name;
GivePlayerMoney( playerid, -hInfo[id][Price] );
DestroyDynamicMapIcon(hInfo[id][Icon]);
PutPlayerInHouse(playerid, id);
new
str[300],
query[400];
format(str, sizeof(str),"House Owned: Yes\nHouse Owner: %s\nHouse Price: $%i\nHouse Locked: %s", hInfo[id][Owner], hInfo[id][Price], (hInfo[id][Locked] == 1) ? ("Yes") : ("No"));
UpdateDynamic3DTextLabelText(Text3D:hInfo[id][Label], 0xFF0000FF, str);
format(query, sizeof(query), "UPDATE `"Houses_Table"` SET `Owned` = '%i', `Owner` = '%s' WHERE `ID` = '%i'",hInfo[id][Owned], hInfo[id][Owner], id);
mysql_query(query);
}
}
}
if(dialogid == BUY_HOUSE && response==1)
{
switch(listitem)
{
case 0:
{
new id = 0, name[25], count = 0;
for(new i=1; i<=CreatedHouses; i++)
{
GetPlayerName(playerid, name, sizeof(name));
if(strcmp(name, hInfo[i][Owner]) == 0)
{
count++;
}
}
if( count >= 3 )
return SendClientMessage(playerid, RED, "ERROR:{FFFFFF} You can't own more than 3 houses at a time");
if( GetPlayerMoney(playerid) < hInfo[id][Price] )
return SendClientMessage(playerid, RED, "ERROR:{FFFFFF} You do not have enough money to buy this house");
for(new i=1; i<=CreatedHouses; i++)//pointless = this is your problem
{
id = i;
break;
}
//count++;
GetPlayerName(playerid, name, 25);
hInfo[id][Owned] = 1;
hInfo[id][Owner] = name;
GivePlayerMoney( playerid, -hInfo[id][Price] );
DestroyDynamicMapIcon(hInfo[id][Icon]);
PutPlayerInHouse(playerid, id);
new
str[300],
query[400];
format(str, sizeof(str),"House Owned: Yes\nHouse Owner: %s\nHouse Price: $%i\nHouse Locked: %s", hInfo[id][Owner], hInfo[id][Price], (hInfo[id][Locked] == 1) ? ("Yes") : ("No"));
UpdateDynamic3DTextLabelText(Text3D:hInfo[id][Label], 0xFF0000FF, str);
format(query, sizeof(query), "UPDATE `"Houses_Table"` SET `Owned` = '%i', `Owner` = '%s' WHERE `ID` = '%i'",hInfo[id][Owned], hInfo[id][Owner], id);
mysql_query(query);
}
}
}
PHP код:
|
[15:42:34] CMySQLHandler::Query(INSERT INTO `Houses` (ID, Owner, Owned, Locked, InteriorID, World, Price, OX, OY, OZ) VALUES ('1', 'None', '0', '0', '2', '1', '66', '2257.017333', '-1338.388793', '23.982807')) - An error has occured. (Error ID: 1062, Duplicate entry '1' for key 'PRIMARY')
[15:42:34] OnQueryError() - Called.
[15:42:37] >> mysql_query( Connection handle: 1 )
[15:42:37] CMySQLHandler::Query(INSERT INTO `Houses` (ID, Owner, Owned, Locked, InteriorID, World, Price, OX, OY, OZ) VALUES ('2', 'None', '0', '0', '1', '2', '66', '2256.829589', '-1349.249023', '24.189058')) - An error has occured. (Error ID: 1062, Duplicate entry '2' for key 'PRIMARY')
[15:42:37] OnQueryError() - Called.
for(new i=1; i<=CreatedHouses; i++)
{
id = i;
break;
}
if(dialogid == BUY_HOUSE && response==1)
{
switch(listitem)
{
case 0:
{
new id = 0, name[MAX_PLAYER_NAME], count = 0;
if( count >= 3 )
return SendClientMessage(playerid, RED, "ERROR:{FFFFFF} You can't own more than 3 houses at a time");
if( GetPlayerMoney(playerid) < hInfo[id][Price] )
return SendClientMessage(playerid, RED, "ERROR:{FFFFFF} You do not have enough money to buy this house");
for(new i = 1; i <= CreatedHouses; i++)
{
if(InPlayerInDynamicCP(playerid, hInfo[i][Owner])) {// change this line!
id = i;
break;
}
}
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
for(new i = 1; i <= CreatedHouses; i++)
{
if(hInfo[i][Owner][0] == '\0') continue; // Add this here to skip unowned houses.
if(strcmp(name, hInfo[i][Owner]) == 0)
count++;
}
hInfo[id][Owned] = 1;
hInfo[id][Owner] = name;
GivePlayerMoney( playerid, -hInfo[id][Price] );
DestroyDynamicMapIcon(hInfo[id][Icon]);
PutPlayerInHouse(playerid, id);
new
str[300],
query[400];
format(str, sizeof(str),"House Owned: Yes\nHouse Owner: %s\nHouse Price: $%i\nHouse Locked: %s", hInfo[id][Owner], hInfo[id][Price], (hInfo[id][Locked] == 1) ? ("Yes") : ("No"));
UpdateDynamic3DTextLabelText(Text3D:hInfo[id][Label], 0xFF0000FF, str);
format(query, sizeof(query), "UPDATE `"Houses_Table"` SET `Owned` = '%i', `Owner` = '%s' WHERE `ID` = '%i'", hInfo[id][Owned], hInfo[id][Owner], id);
mysql_query(query);
}
}
}
You using pickups or checkpoints?
What is the variable name of the created pickup/checkpoint? E.G hInfo[id][DynamicCheckpointID] EDIT: I didn't see your last post, the error in your code is pawn Код:
BTW: don't use 25 for max player name, the max player name is actually 20 based on the client so use 21, or just use the define MAX_PLAYER_NAME which is set to 24. pawn Код:
|