[22:30:28] CMySQLHandler::Query(resultID) - Threaded query with id 18 started. (Extra ID: 0) [22:30:28] CMySQLHandler::ProcessQueryThread(UPDATE `houses` SET `HName` = 'test' WHERE `HouseID` = '-255') - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes) [22:30:28] OnQueryFinish(18,"UPDATE `houses` SET `HName` = 'test' WHERE `HouseID` = '-255'") - Called. |
if(strlen(inputtext) > 2 && strlen(inputtext) < 21)
{
new housenumber = GetHouseID( playerid );
if ( strcmp( GetGVarStringEx( "h_Owner", housenumber ), PlayerName( playerid ), false ) )
return SendClientMessage( playerid, -1,""SV_RD"» {c8c8c8}This house isn't yours!" );
format( gsQuery, sizeof gsQuery, "UPDATE `houses` SET `HName` = '%s' WHERE `HouseID` = '%d'", inputtext, housenumber );
mysql_query( gsQuery, THREAD_NONE, playerid );
SetGVarString( "h_name", "%s", housenumber );
format( gsString, sizeof( gsString ), ""W"Press "ORANGE_"H "W"key to Enter the House\n"SV_BL"House Name: "W"%s\n"SV_BL"House Owner: "W"%s\n "SV_BL"House Value: "W"%d$\n "SV_BL"House Privacy: "RED_"Closed\n"SV_BL"House ID: "ORANGE_"%d",GetGVarStringEx( "h_name", housenumber ), PlayerName(playerid), GetGVarInt( "h_Cost", housenumber),housenumber);
UpdateDynamic3DTextLabelText( Text3D:GetGVarInt( "House3DText", housenumber ), 0xFF9900FF, gsString );
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error: {ffffff}You must enter 2-20 Character.");
ShowPlayerDialog(playerid, DIALOG_HOUSE_NAME, DIALOG_STYLE_INPUT, "House Name", "Write a new name for this house:\n\n{E74C3C}The name you entered is either too short or too long.", "Change", "Back");
}
stock GetHouseID( playerid )
{
for ( new i = 0; i < MAX_HOUSES; i++ )
if ( IsPlayerInRangeOfPoint( playerid, 2.0, GetGVarFloat( "h_X", i ), GetGVarFloat( "h_Y", i ), GetGVarFloat( "h_Z", i ) ) )
return i;
return -255;
}
stock GetHouseID( playerid )
{
new id;
id = -255;
for ( new i = 0; i < MAX_HOUSES; i++ )
if (IsPlayerInRangeOfPoint( playerid, 2.0, GetGVarFloat( "h_X", i ), GetGVarFloat( "h_Y", i ), GetGVarFloat( "h_Z", i ))) id = i;
print(id);
return id;
}
I think I know now what could be the problem. I need to be in a range of IsPlayerInRangeOfPoint( playerid, 2.0..) (which is near the house icon pickup) in order to save the GetHouseID if not then it will return as -255.
|
if(listitem == 0)
{
ShowPlayerDialog(playerid, DIALOG_HOUSE_NAME, DIALOG_STYLE_INPUT, "House Name", "Write a new name for this house:", "Change", "Back");
}
if(dialogid == DIALOG_HOUSE_NAME)
{
if ( !response ) return 1;
if ( response )
{
if(strlen(inputtext) > 2 && strlen(inputtext) < 21)
{
SetCameraBehindPlayer(playerid);
SetPlayerPos( playerid, housex-0.5 , housey, housez );
SetPlayerInterior( playerid, 0 );
TogglePlayerControllable(playerid,0);
SetTimerEx("WarningUnfreeze",4000,false,"id",playerid,GetPlayerVirtualWorld(playerid));
SetTimerEx("housename",3000,false,"id",playerid);
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error: {ffffff}You must enter 2-20 Character.");
ShowPlayerDialog(playerid, DIALOG_HOUSE_NAME, DIALOG_STYLE_INPUT, "House Name", "Write a new name for this house:\n\n{E74C3C}The name you entered is either too short or too long.", "Change", "Back");
}
}
}
SetTimerEx("housename",3000,false,"id",playerid) <--- Dialog 2;
forward housename(playerid);
public housename(playerid)
{
new housenumber = GetHouseID( playerid );
if ( strcmp( GetGVarStringEx( "h_Owner", housenumber ), PlayerName( playerid ), false ) )
return SendClientMessage( playerid, -1,""SV_RD"» {c8c8c8}This house isn't yours!" );
format( gsQuery, sizeof gsQuery, "UPDATE `houses` SET `HName` = '%s' WHERE `HouseID` = '%d'", inputtext, housenumber );
mysql_query( gsQuery, THREAD_NONE, playerid );
SetGVarString( "h_name", "%s", housenumber );
format( gsString, sizeof( gsString ), ""W"Press "ORANGE_"H "W"key to Enter the House\n"SV_BL"House Name: "W"%s\n"SV_BL"House Owner: "W"%s\n "SV_BL"House Value: "W"%d$\n "SV_BL"House Privacy: "RED_"Closed\n"SV_BL"House ID: "ORANGE_"%d",GetGVarStringEx( "h_name", housenumber ), PlayerName(playerid), GetGVarInt( "h_Cost", housenumber),housenumber);
UpdateDynamic3DTextLabelText( Text3D:GetGVarInt( "House3DText", housenumber ), 0xFF9900FF, gsString );
return 1;
}
(22602) : error 017: undefined symbol "inputtext" |
SetTimerEx("housename",3000,false,"is",playerid, inputtext); |
You can't and you don't need to.
There is no need for those timers, you can check player's position before setting house name, and also you need to escape house name, otherwise someone will f*ck you up with sql injection. |
[10:30:49] CMySQLHandler::Query(resultID) - Threaded query with id 18 started. (Extra ID: 0) [10:30:49] CMySQLHandler::ProcessQueryThread(UPDATE `houses` SET `HName` = 'test' WHERE `HouseID` = '-255') - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes) [10:30:49] OnQueryFinish(18,"UPDATE `houses` SET `HName` = 'test' WHERE `HouseID` = '-255'") - Called. |
if(strlen(inputtext) > 2 && strlen(inputtext) < 21)
{
SetCameraBehindPlayer(playerid);
SetPlayerInterior( playerid, 0 );
TogglePlayerControllable(playerid,0);
SetPlayerPos( playerid, housex-0.5 , housey, housez ); //check last position before entering the house
SetTimerEx("WarningUnfreeze",4000,false,"id",playerid,GetPlayerVirtualWorld(playerid));
new housenumber = GetHouseID( playerid );
if ( strcmp( GetGVarStringEx( "h_Owner", housenumber ), PlayerName( playerid ), false ) )
return SendClientMessage( playerid, -1,""SV_RD"» {c8c8c8}This house isn't yours!" );
format( gsQuery, sizeof gsQuery, "UPDATE `houses` SET `HName` = '%s' WHERE `HouseID` = '%d'", inputtext, housenumber );
mysql_query( gsQuery, THREAD_NONE, playerid );
SetGVarString( "h_name", "%s", housenumber );
format( gsString, sizeof( gsString ), ""W"Press "ORANGE_"H "W"key to Enter the House\n"SV_BL"House Name: "W"%s\n"SV_BL"House Owner: "W"%s\n "SV_BL"House Value: "W"%d$\n "SV_BL"House Privacy: "RED_"Closed\n"SV_BL"House ID: "ORANGE_"%d",GetGVarStringEx( "h_name", housenumber ), PlayerName(playerid), GetGVarInt( "h_Cost", housenumber),housenumber);
UpdateDynamic3DTextLabelText( Text3D:GetGVarInt( "House3DText", housenumber ), 0xFF9900FF, gsString );
}
SetTimerEx("housename",3000,false,"is",playerid, inputtext);