CMD:addfac(playerid, params[])
{
new fac[40], var100[60];
if(!IsManager(playerid)) return SCM(playerid, COLOR_ERROR, "Nu ai gradul necesar ca sa folosesti aceasta comanda!");
if(sscanf(params,"s[40]", fac)) return SCM(playerid, COLOR_SYN, "Sintaxa:{FFFFFF} /addfac [Nume Factiune]");
{
new Float:POSX, Float:POSY, Float:POSZ;
GetPlayerPos(playerid, POSX, POSY, POSZ);
gQuery[0] = (EOS);
mysql_format(handle, gQuery, sizeof(gQuery), "INSERT INTO `factions` (`Name`,`ExitX`,`ExitY`,`ExitZ`,`Slots`,`MinLevel`,`Application`,`News`) VALUES ('%s','%f','%f','%f','10','5','0','Bun venit in %s')", fac, POSX, POSY, POSZ, fac);
mysql_query(handle, gQuery);
format(var100, sizeof(var100), "Ai adaugat factiunea [%s].", fac);
SCM(playerid, COLOR_WHITE, var100);
defer EditFaction(playerid);
}
return 1;
}
|
Nothing in this code creates the pickup, so the next thing to look at EditFaction if that updates the location of the pickup/3dtext/etc.
|
gQuery[0] = (EOS); mysql_format(handle, gQuery, sizeof(gQuery), "SELECT * FROM `factions`"); mysql_tquery(handle, gQuery, "LoadFactions", "");
function LoadFactions()
{
factionss = cache_num_rows();
new string[64], tmp[128], id;
for(new i = 0; i < factionss; i++)
{
cache_get_field_content(i, "ID", tmp); id = strval(tmp);
cache_get_field_content(i, "ID", tmp); FactionInfo[id][fID] = strval(tmp);
cache_get_field_content(i, "Name", tmp); strmid(FactionInfo[id][fName], tmp, false, strlen(tmp), 32);
cache_get_field_content(i, "SpawnX", tmp); FactionInfo[id][fSpawnX] = strval(tmp);
cache_get_field_content(i, "SpawnY", tmp); FactionInfo[id][fSpawnY] = strval(tmp);
cache_get_field_content(i, "SpawnZ", tmp); FactionInfo[id][fSpawnZ] = strval(tmp);
cache_get_field_content(i, "ExitX", tmp); FactionInfo[id][fExitX] = strval(tmp);
cache_get_field_content(i, "ExitY", tmp); FactionInfo[id][fExitY] = strval(tmp);
cache_get_field_content(i, "ExitZ", tmp); FactionInfo[id][fExitZ] = strval(tmp);
cache_get_field_content(i, "Interior", tmp); FactionInfo[id][fInterior] = strval(tmp);
cache_get_field_content(i, "VirtualW", tmp); FactionInfo[id][fVirtualW] = strval(tmp);
cache_get_field_content(i, "MinLevel", tmp); FactionInfo[id][fMinLevel] = strval(tmp);
cache_get_field_content(i, "Slots", tmp); FactionInfo[id][fSlots] = strval(tmp);
cache_get_field_content(i, "Application", tmp); FactionInfo[id][fApplication] = strval(tmp);
cache_get_field_content(i, "News", tmp); strmid(FactionInfo[id][fNews], tmp, false, strlen(tmp), 128);
FactionInfo[id][fPickupIDIesire] = CreateDynamicPickup(19132, 1, FactionInfo[id][fSpawnX], FactionInfo[id][fSpawnY], FactionInfo[id][fSpawnZ], -1, -1, -1, 30.0);
FactionInfo[id][fPickupIDIntrare] = CreateDynamicPickup(19132, 1, FactionInfo[id][fExitX], FactionInfo[id][fExitY], FactionInfo[id][fExitZ], -1, -1, -1, 30.0);
format(string, sizeof(string), "%s\nIesire", FactionInfo[id][fName]);
FactionInfo[id][fLabelIDIesire] = CreateDynamic3DTextLabel(string, COLOR_WHITE, FactionInfo[id][fSpawnX], FactionInfo[id][fSpawnY], FactionInfo[id][fSpawnZ], 30, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 30.0);
format(string, sizeof(string), "%s\nIntrare", FactionInfo[id][fName]);
FactionInfo[id][fLabelIDIntrare] = CreateDynamic3DTextLabel(string, COLOR_WHITE, FactionInfo[id][fExitX], FactionInfo[id][fExitY], FactionInfo[id][fExitZ], 30, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 30.0);
}
printf("S-au incarcat %d factiuni.", factionss);
return 1;
}
cache_get_field_content(i, "SpawnX", tmp); FactionInfo[id][fSpawnX] = strval(tmp);
cache_get_field_content(i, "SpawnY", tmp); FactionInfo[id][fSpawnY] = strval(tmp);
cache_get_field_content(i, "SpawnZ", tmp); FactionInfo[id][fSpawnZ] = strval(tmp);
cache_get_field_content(i, "ExitX", tmp); FactionInfo[id][fExitX] = strval(tmp);
cache_get_field_content(i, "ExitY", tmp); FactionInfo[id][fExitY] = strval(tmp);
cache_get_field_content(i, "ExitZ", tmp); FactionInfo[id][fExitZ] = strval(tmp);
new floatNumber[7] = "15.623";
printf("%f", strval(floatNumber));
strval("6.23") ==> 6
strval("96494.544") ==> 96494
strval("1.0") ==> 1
X = 1663.2345 Y = -4959.2783 Z = 3.296
strval(X) = 1663 strval(Y) = -4959 strval(Z) = 3
cache_get_field_content(i, "SpawnX", tmp); FactionInfo[id][fSpawnX] = floatstr(tmp);
cache_get_field_content(i, "SpawnY", tmp); FactionInfo[id][fSpawnY] = floatstr(tmp);
cache_get_field_content(i, "SpawnZ", tmp); FactionInfo[id][fSpawnZ] = floatstr(tmp);
cache_get_field_content(i, "ExitX", tmp); FactionInfo[id][fExitX] = floatstr(tmp);
cache_get_field_content(i, "ExitY", tmp); FactionInfo[id][fExitY] = floatstr(tmp);
cache_get_field_content(i, "ExitZ", tmp); FactionInfo[id][fExitZ] = floatstr(tmp);
mysql_query(handle, gQuery); Replace with: mysql_tquery(handle, qQuery, "", ""); And FactionInfo[id][fExitY] = floatstr(tmp); Replace with: FactionInfo[id][fExitY] = floatstr(tmp);
FactionInfo[id][fSpawnX] = cache_get_field_content_float(i, "SpawnX");