Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_mysql>
- #include <zcmd>
- #include <sscanf2>
- #define DB_SERVER "127.0.0.1"
- #define DB_USER "root"
- #define DB_DB "samp"
- #define DB_PASS ""
- #define MAX_BUILDING (100)
- enum buildingEnum {
- b_name[27],
- Float:b_pos[3],
- Float:b_i_pos[3],
- b_interior,
- b_virtuall
- };
- new
- dbHandle,
- bInfo[MAX_BUILDING][buildingEnum];
- public OnGameModeInit()
- {
- mysql_function_query(dbHandle,"SELECT * FROM building",false,"loadBuildings","");
- return 1;
- }
- COMMAND:addbuilding(playerid,params[])
- {
- if(sscanf(params,"s[26]dd",params[0],params[1],params[2]))
- return SendClientMessage(playerid,-1,"[Usage]: /addbuilding [building name] [building interior] [building virtual]");
- new
- gQuery[246],
- Float:gPos[MAX_PLAYERS][3];
- GetPlayerPos(playerid,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2]);
- format(gQuery,246,"INSERT INTO building (b_name,b_int,b_virtual,b_x,b_y,b_z,b_i_x,b_i_y,b_i_z) VALUES(%s,%d,%d,%f,%f,%f,0.0,0.0,0.0)",params[0],params[1],params[2],gPos[playerid][0],gPos[playerid][1],gPos[playerid][2]);
- mysql_function_query(dbHandle,gQuery,246,"","");
- new localString[246];
- CreatePickup(1239,2,bInfo[playerid][b_pos][0],bInfo[playerid][b_pos][1],bInfo[playerid][b_pos][2]);
- format(localString,128,"Building Name: %s",bInfo[playerid][b_name]);
- Create3DTextLabel(localString, -1, 30.0, 40.0, 50.0, 40.0, 0, 0);
- format(localString,124,"[Success]: you successufulli created a build, continnue fun game!");
- SendClientMessage(playerid,-1,localString);
- return 1;
- }
- COMMAND:enter(playerid,params[])
- {
- for(new i; i != MAX_BUILDING; i++)
- {
- if(!IsPlayerInRangeOfPoint(playerid,2.0,bInfo[i][b_pos][0],bInfo[i][b_pos][1],bInfo[i][b_pos][2])) continue;
- SetPlayerPos(playerid,bInfo[i][b_i_pos][0],bInfo[i][b_i_pos][1],bInfo[i][b_i_pos][2]);
- SetPlayerInterior(playerid,bInfo[i][b_interior]);
- SetPlayerVirtualWorld(playerid,bInfo[i][b_virtuall]);
- }
- return 1;
- }
- COMMAND:exit(playerid,params[])
- {
- for(new i; i != MAX_BUILDING; i++)
- {
- if(!IsPlayerInRangeOfPoint(playerid,2.0,bInfo[i][b_i_pos][0],bInfo[i][b_i_pos][1],bInfo[i][b_i_pos][2])) continue;
- SetPlayerPos(playerid,bInfo[i][b_pos][0],bInfo[i][b_pos][1],bInfo[i][b_pos][2]);
- SetPlayerInterior(playerid,0);
- SetPlayerVirtualWorld(playerid,0);
- }
- return 1;
- }
- forward loadBuildings();
- public loadBuildings()
- {
- for(new i; i != MAX_BUILDING; i++)
- {
- cache_get_field_content(0,"b_name",bInfo[i][b_name],dbHandle);
- bInfo[i][b_pos][0] = cache_get_field_content_float(0,"b_x",dbHandle);
- bInfo[i][b_pos][1] = cache_get_field_content_float(0,"b_y",dbHandle);
- bInfo[i][b_pos][2] = cache_get_field_content_float(0,"b_z",dbHandle);
- bInfo[i][b_i_pos][0] = cache_get_field_content_float(0,"b_i_x",dbHandle);
- bInfo[i][b_i_pos][1] = cache_get_field_content_float(0,"b_i_y",dbHandle);
- bInfo[i][b_i_pos][2] = cache_get_field_content_float(0,"b_i_z",dbHandle);
- bInfo[i][b_interior] = cache_get_field_content_int(0,"b_int",dbHandle);
- bInfo[i][b_virtuall] = cache_get_field_content_int(0,"b_virtual",dbHandle);
- }
- SetTimer("loadAllBuilding",2000,false);
- return 1;
- }
- forward loadAllBuilding();
- public loadAllBuilding()
- {
- new localString[128];
- for(new i; i != MAX_BUILDING; i++)
- {
- CreatePickup(1239,2,bInfo[i][b_pos][0],bInfo[i][b_pos][1],bInfo[i][b_pos][2]);
- format(localString,128,"Building Name: %s",bInfo[i][b_name]);
- }
- Create3DTextLabel(localString, -1, 30.0, 40.0, 50.0, 40.0, 0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment