19.08.2016, 06:15
Bro.. How to make cmd /hmenu to /Buy or Changeinterior?
I use MYSQL DATA...
I use MYSQL DATA...
PHP код:
CMD:createmansion(playerid,params[])
{
new str[30];
format(str,sizeof(str),"12000000 0 %d",mansions[random(sizeof(mansions))]);
cmd_createhouse(playerid,str);
return 1;
}
CMD:gotohouse(playerid,params[])
{
if(PlayerInfo[ playerid ][ ActionID ] != 0 || PlayerInfo[ playerid ][ Challenge ] == 1) return SendClientMessage(playerid,-1,"{FF0000}ERROR: {C8C8C8}You can't teleport to houses while in a DM!");
new i;
if(sscanf(params, "d", i)) return SendClientMessage( playerid, COLOR_ULTRARED, "{15D4ED}INFO: {FFE4C4}Type /gohouse <ID> to teleport to a house ID." ),ShowPlayerDialog( playerid, DIALOG_EMPTY, DIALOG_STYLE_MSGBOX, ""ORANGE_"NFS:"LIGHTBLUE_"Houses", ""W"Usage:/gotohouse (houseid)", "Close", "" );
if(i > 999) return ShowPlayerDialog( playerid, DIALOG_EMPTY, DIALOG_STYLE_MSGBOX, ""ORANGE_"NFS:"LIGHTBLUE_"Houses", ""W"Invalid house ID. This house ID does not exist.", "Close", "" );
if(i >= 0)
{
new lstring[256];
format(lstring,256,""W"You have teleported to house ID "LBLUE_"%d"W".",i);
ShowPlayerDialog( playerid, DIALOG_EMPTY, DIALOG_STYLE_MSGBOX, ""ORANGE_"NFS:"LIGHTBLUE_"Houses", lstring, "Close", "" );
SetPlayerPos(playerid,hInfo[i][sX],hInfo[i][sY],hInfo[i][sZ]);
SetPlayerFacingAngle(playerid,hInfo[i][SpawnA]);
}
return 1;
}
CMD:houses( playerid, params[ ] )
{
gsString[ 0 ] = EOS;
new V;
new lstring[5000];
format( lstring, sizeof( lstring ), "%s"DBLUE_"There are %d houses available:\n\n",lstring,CountHouses());
for(new i = 0; i < sizeof(hInfo); i++)
{
if(hInfo[i][hOwnerID] == -255)
{
format( lstring, sizeof( lstring ), "%s"W"%d) {FFE4C4}House ID: %d "GRI"(Location: Unknown) (Price: "GREEN_"$%s"GRI")\n",lstring,V,i,FormatNumber( hInfo[i][Cost] ) );
V++;
}
}
if ( V == 0 )
format( lstring, sizeof( lstring ), "{FF0000}No house is available for sale!" );
return ShowPlayerDialog( playerid, DIALOG_EMPTY, DIALOG_STYLE_MSGBOX, "{FFE4C4}House List", lstring, "Quit", "" );
}
stock CountHouses()
{
new count;
for(new i = 0; i < sizeof(hInfo); i++)
{
if(hInfo[i][hOwnerID] == -255) count++;
}
return count;
}
CMD:createhouse(playerid,params[])
{
if ( !IsPlayerAdmin( playerid ) )
return SendError( playerid, " {C8C8C8}You are not authorized to use this command!" );
new PrIcE,b,vip;
if(sscanf(params,"ddd",PrIcE,vip,b))
return SendClientMessage( playerid, COLOR_ULTRARED,""R"/Createhouse <price> <Vip (1/0)> <interior> ")
,SendClientMessage(playerid,0x9DDB79FF,"*{368C00} You can use {9DDB79}/create(caravan/smallhouse/bighouse/villa/mansion){368C00} for a faster house creation");
if(vip != 0 && vip != 1) return SendClientMessage( playerid, COLOR_ULTRARED,""R"Invalid value for VIP entered!");
if(b < 0 || b > sizeof(HouseInteriors)) return SendClientMessage( playerid, COLOR_ULTRARED,""R"invalid interior ,use /interiors to see the list with available interiors");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
format( gsQuery, sizeof gsQuery, "INSERT INTO `houses` VALUES(0,'House For Sale!','No Owner', '%d', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d','0','-255','0')",PrIcE,x,y,z,x,y,z,a,b,vip);
mysql_query( gsQuery );
new HouseIntID;
HouseIntID = mysql_insert_id( );
hExist[HouseIntID]=true;
format(hInfo[ HouseIntID ][ Name ],50,"House For Sale!");
format(hInfo[ HouseIntID ][ Owner ],24,"No Owner");
hInfo[ HouseIntID ][ hOwnerID ] = -255;
hInfo[ HouseIntID ][ Cost ] =PrIcE;
hInfo[ HouseIntID ][ ExteriorX ]= x;
hInfo[ HouseIntID ][ ExteriorY ]= y;
hInfo[ HouseIntID ][ ExteriorZ ]= z;
hInfo[ HouseIntID ][ sX ] = x;
hInfo[ HouseIntID ][ sY ] = y;
hInfo[ HouseIntID ][ sZ ] = z;
hInfo[ HouseIntID ][ SpawnA ] = a;
hInfo[ HouseIntID ][ PP ] = vip;
hInfo[HouseIntID ][Interior] = b;
hInfo[HouseIntID ][VirtualWorld] = Hvw;
hInfo[ HouseIntID ][ hLocked ] =0;
HousePickup[HouseIntID] = CreatePickup(1273, 23, x, y, z);
HouseIcon[HouseIntID] = CreateDynamicMapIcon(x,y,z,31,0,0,-1,-1,500.0);
new str[1000];
format(str,sizeof(str),""LIGHTBLUE_"House Name: "W"%s\n"LIGHTBLUE_"House Owner: "W"No Owner\n "LIGHTBLUE_"House Value: "W"%d$\n"LIGHTBLUE_"For Sale: "W"Yes\n"LIGHTBLUE_"House ID: "ORANGE_"%d",hInfo[ HouseIntID ][ Name ],hInfo[ HouseIntID ][ Cost ],HouseIntID);
House3D[HouseIntID]=CreateDynamic3DTextLabel( str, ~1,x,y,z, 40.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1 ,0);
format(str,sizeof(str)," {FF6600}» House Editor «{FFE100}House id %d has been created",HouseIntID);
SendClientMessage(playerid,0xFFE100FF,str);
SendClientMessage(playerid,-1,"Use (/housespawn) spawn position on this house");
Hvw++;
ResetHouseTimeStamp(HouseIntID);
return 1;
}
CMD:deletehouse(playerid,params[])
{
new iD;
LevelCheck( playerid, 10 );
if(sscanf(params,"i",iD)) return SendClientMessage( playerid, COLOR_ULTRARED,""R"/deletehouse <HouseID>");
if(iD > 999) return ShowPlayerDialog( playerid, DIALOG_EMPTY, DIALOG_STYLE_MSGBOX, ""ORANGE_"NFS:"LIGHTBLUE_"Houses", ""W"Invalid house ID. This house ID does not exist.", "Close", "" );
if(hInfo[ iD ][ hOwnerID ] > 0) return SendClientMessage( playerid, COLOR_ULTRARED,""R"You must approve this house before removing it");
if(!IsPlayerInRangeOfPoint(playerid,20.0,hInfo[ iD ][ ExteriorX ],hInfo[ iD ][ ExteriorY ],hInfo[ iD ][ ExteriorZ ])) return SendClientMessage( playerid, COLOR_ULTRARED,""R"You must be near the house");
hInfo[ iD ][ hOwnerID ]= -255;
hInfo[ iD ][ ExteriorX ]= 0.0;
hInfo[ iD ][ ExteriorY ]= 0.0;
hInfo[ iD ][ ExteriorZ ]= 0.0;
hInfo[ iD ][ sX ] = 0.0;
hInfo[ iD ][ sY ] = 0.0;
hInfo[ iD ][ sZ ] = 0.0;
hInfo[ iD ][ SpawnA ] = 0.0;
DestroyPickup(HousePickup[iD]);
DestroyDynamicMapIcon(HouseIcon[iD]);
HouseIcon[iD]=-1,HousePickup[iD]=-1;
Delete3DTextLabel(House3D[iD]);
new str[128];
format(str,sizeof(str),"House id %d has been removed",iD);
SendClientMessage(playerid,-1,str);
format( gsQuery, 128, "DELETE FROM `houses` WHERE `ID` = '%d'",iD);
mysql_query( gsQuery, THREAD_NONE, playerid );
hExist[iD]=false;
return 1;
}
CMD:house(playerid,params[])
{
if(PlayerInfo[ playerid ][ ActionID ] != 0 || PlayerInfo[ playerid ][ Challenge ] == 1) return SendClientMessage(playerid,-1,"{FF0000}ERROR: {C8C8C8}You can't use this command while in a DM!");
if(gettime() - HouseWait[playerid] < 180) return SendClientMessage( playerid, COLOR_ULTRARED,""R"This command can only be used once in 3 minutes");
HouseWait[playerid]=gettime();
new h=PlayerInfo[playerid][pHouse];
if(h >= 0)
{
new b=hInfo[h][Interior];
SetPlayerPos(playerid,HouseInteriors[b][IntPos][0],HouseInteriors[b][IntPos][1],HouseInteriors[b][IntPos][2]);
SetPlayerFacingAngle(playerid,HouseInteriors[b][IntPos][3]);
SetPlayerInterior(playerid,HouseInteriors[b][IntID]);
SetPlayerVirtualWorld(playerid,hInfo[h][VirtualWorld]);
InHouse[playerid]=h;
}
else SendClientMessage( playerid, COLOR_ULTRARED,"{FF0000}ERROR: {C8C8C8}You do not own a house!");
return 1;
}
CMD:housespawn(playerid,params[])
{
new iD;
LevelCheck( playerid, 10 );
if(sscanf(params,"d",iD)) return SendClientMessage( playerid, COLOR_ULTRARED,""R"/HoudeSpawn <HouseID>");
if(iD > 999) return ShowPlayerDialog( playerid, DIALOG_EMPTY, DIALOG_STYLE_MSGBOX, ""ORANGE_"NFS:"LIGHTBLUE_"Houses", ""W"Invalid house ID. This house ID does not exist.", "Close", "" );
if(!IsPlayerInRangeOfPoint(playerid,15.0,hInfo[ iD ][ ExteriorX ],hInfo[ iD ][ ExteriorY ],hInfo[ iD ][ ExteriorZ ])) return SendClientMessage( playerid, COLOR_ULTRARED,""R"You must be near the house");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
hInfo[ iD ][ sX ] = x;
hInfo[ iD ][ sY ] = y;
hInfo[ iD ][ sZ ] = z;
hInfo[ iD ][ SpawnA ] = a;
new str[128];
format(str,sizeof(str)," {FF6600}»House« {FFE100}House id %d Spawn Point has been changed",iD);
SendClientMessage(playerid,-1,str);
format( gsQuery, sizeof gsQuery,"UPDATE `houses` SET `SpawnX`=%f,`SpawnY`=%f,`SpawnZ`=%f,`SpawnA`=%f WHERE `ID` = %d",hInfo[ iD ][ sX ],hInfo[ iD ][ sY ],hInfo[ iD ][ sZ ],hInfo[ iD ][ SpawnA ], iD );
mysql_query( gsQuery, THREAD_NONE, playerid );
return 1;
}