COMMAND:buildsam(playerid,params[])
{
editing = 2;
GetPlayerPos(playerid,p_x,p_y,p_z);
tmp_sam[playerid] = CreateObject(3267, p_x, p_y, p_z, 0.0, 0.0, 0.0);
EditObject(playerid, tmp_sam[playerid]);
return 1;
}
if(editing ==2)
{
for(new i=0; i<sizeof(SAInfo); i++)
{
if(SAInfo[i][s_id]==0)
{
SAInfo[i][s_x] = fX;
SAInfo[i][s_y] = fY;
SAInfo[i][s_z] = fZ;
SAInfo[i][s_rx] = fRotX;
SAInfo[i][s_ry] = fRotY;
SAInfo[i][s_rz] = fRotX;
SAInfo[i][s_range] = 300;
Create3DTextLabel("ok", -1, fX, fY, fZ, 30, 0, 0);
new query[256];
format(query, sizeof(query),"INSERT INTO sam (s_x, s_y, s_z, s_rx, s_ry, s_rz, s_range, s_type) VALUES ('%f', '%f', '%f', '%f', '%f', '%f','%i', '%s')",SAInfo[i][s_x], SAInfo[i][s_y], SAInfo[i][s_z], SAInfo[i][s_rx], SAInfo[i][s_ry], SAInfo[i][s_rz],SAInfo[i][s_range], "Blown");
mysql_function_query(dbhandle, query, true, "OnSamCreated", "");
SendClientMessage(playerid,COLOR_GREEN,"SAM created successfully!");
DestroyObject(tmp_sam[playerid]);
return 1;
}
}
return 1;
}
UpdateSAM(id)
{
if(strlen(SAInfo[id][s_id])){
new string[138];
SAInfo[id][s_obj]=CreateObject(3267, SAInfo[id][s_x], SAInfo[id][s_y], SAInfo[id][s_z], SAInfo[id][s_rx], SAInfo[id][s_ry], SAInfo[id][s_rz]);
format(string, sizeof(string), "SAM ID : %i\nSAM Type : %s\nRange : %i\n{FF2400}Enabled", id,SAInfo[id][s_type],SAInfo[id][s_range]);
SAInfo[id][s_label] = Create3DTextLabel(string, COLOR_WHITE, SAInfo[id][s_x], SAInfo[id][s_y], SAInfo[id][s_z], 30, 0,0);
}
return 1;
}
format(query, sizeof(query), "SELECT * FROM sam");
mysql_function_query(dbhandle, query, true, "OnSAMLoad", "");
public OnSAMLoad()
{
new num_fields,num_rows;
cache_get_data(num_rows,num_fields,dbhandle);
if(!num_rows)return 1;
for(new i=0; i<num_rows; i++)
{
SAInfo[i][s_id]=cache_get_field_content_int(i, "id",dbhandle);
SAInfo[i][s_x]=cache_get_field_content_float(i, "s_x",dbhandle);
SAInfo[i][s_y]=cache_get_field_content_float(i, "s_y",dbhandle);
SAInfo[i][s_z]=cache_get_field_content_float(i, "s_z",dbhandle);
SAInfo[i][s_rx]=cache_get_field_content_float(i, "s_rx",dbhandle);
SAInfo[i][s_ry]=cache_get_field_content_float(i, "s_ry",dbhandle);
SAInfo[i][s_rz]=cache_get_field_content_float(i, "s_rz",dbhandle);
SAInfo[i][s_range]=cache_get_field_content_int(i, "s_range", dbhandle);
new tmp_type[20];
cache_get_field_content(i, "s_type", tmp_type);
strmid(SAInfo[i][s_type], tmp_type, 0, sizeof(tmp_type), sizeof(tmp_type));
//new m[126];
//format(m, sizeof(m), "ICON POST : %f,%f,%f | Interiror : %f,%f,%f", bInfo[id][b_x],bInfo[id][b_y],bInfo[id][b_z],bInfo[id][b_ix],bInfo[id][b_iyy],bInfo[id][b_izz]);
//SendClientMessageToAll(-1, m);
UpdateSAM(i);
}
return 1;
}
OnSAMLoad:
PHP код:
|