05.07.2015, 22:20
So im having some problems, when i buy vehicle i want when player locks it noone can enter but i can't manage to do it, and idk why this is command for buying:
This is loading
And this is locking:
Now i've tried everything but i can't manage it to work and idk why, please help me.
pawn Код:
case DIALOG_AUTOBUY:
{
if(response)
{
new query[1204], str[128], id = SpawnedAutomobila+1;
if(PI[playerid][Auto] != -1) return SCM(playerid, TOMATO, "[RPF] {FFFFFF}Vec imate auto.");
if(PI[playerid][Novac] < AutomobilCena[playerid]) return SCM(playerid, TOMATO, "[RPF] {FFFFFF}Nemate dovoljno novca za kupovinu ovog vozila.");
GPSOn[playerid] = 1;
new poz = random(sizeof(PozicijeAutomobila));
VInfo[id][Model] = AutoBiraModel[playerid];
VInfo[id][PozX] = PozicijeAutomobila[poz][0];
VInfo[id][PozY] = PozicijeAutomobila[poz][1];
VInfo[id][PozZ] = PozicijeAutomobila[poz][2];
VInfo[id][PozA] = PozicijeAutomobila[poz][3];
VInfo[id][VW] = 0;
VInfo[id][Int] = 0;
VInfo[id][Boja1] = 0;
VInfo[id][Boja2] = 0;
strmid(VInfo[id][Vlasnik], ImeIgraca(playerid), 0, strlen(ImeIgraca(playerid)), 255);
VInfo[id][Cena] = AutomobilCena[playerid];
VInfo[id][Locked] = 0;
VInfo[id][Droga] = 0;
VInfo[id][Mats] = 0;
VInfo[id][Oruzje1] = -1;
VInfo[id][Oruzje2] = -1;
VInfo[id][Oruzje3] = -1;
VInfo[id][Municija1] = -1;
VInfo[id][Municija2] = -1;
VInfo[id][Municija3] = -1;
AutoBiraModel[playerid] = 0;
AutomobilCena[playerid] = -1;
SpawnedAutomobila++;
PI[playerid][Auto] = id;
format(str, sizeof(str), ""COL_YELLOW"[SERVER]: "COL_WHITE"Cestitamo, kupili ste vozilo "COL_YELLOW"%s "COL_WHITE"po ceni od "COL_YELLOW"$%d.", ImenaVozila[VInfo[id][Model] - 400], VInfo[id][Cena]);
SCM(playerid, WHITE, str);
SCM(playerid, WHITE, ""COL_YELLOW"[SERVER]: "COL_WHITE"Dostupne komande vaseg auta mozete videti na "COL_YELLOW"/v.");
VInfo[id][ownedvehicle] = CreateVehicle_H(VInfo[id][Model], VInfo[id][PozX], VInfo[id][PozY], VInfo[id][PozZ], VInfo[id][PozA], VInfo[id][Boja1], VInfo[id][Boja2], 300000);
SetVehicleToRespawn(VInfo[id][ownedvehicle]);
SetPlayerCheckpoint(playerid, VInfo[id][PozX], VInfo[id][PozY], VInfo[id][PozZ], 10.0);
format(query, sizeof(query), "UPDATE `Igraci` SET `Auto` = '%d' WHERE `Ime` = '%s'", PI[playerid][Auto], ImeIgraca(playerid));
mysql_function_query(konekt, query, true, "OnQueryFinish", "ii", THREAD_OSTALO, playerid);
format(query, sizeof(query), "INSERT INTO `Automobili` (`ID`, `Model`, `PozX`, `PozY`, `PozZ`, `PozA`, `VW`, `Int`, `Zakljucan`, `Boja1`, `Boja2`, \
`Vlasnik`, `Cena`, `ImaVlasnika`, `Droga`, `Oruzje1`, `Oruzje2`, `Oruzje3`, `Municija1`, `Municija2`, `Municija3`) VALUES");
format(query, sizeof(query), "%s ('%d', '%d', '%f', '%f', '%f', '%f', '0', '0', '0', '0', '0', '%s', '%d', '1', '0', '-1', '-1', '-1', '-1', '-1', '-1')",
query, id, VInfo[id][Model], VInfo[id][PozX], VInfo[id][PozY], VInfo[id][PozZ], VInfo[id][PozA], VInfo[id][Vlasnik], VInfo[id][Cena]);
mysql_function_query(konekt, query, true, "OnQueryFinish", "i", THREAD_OSTALO);
}
else
{
AutoBiraModel[playerid] = 0;
AutomobilCena[playerid] = -1;
SCM(playerid, TOMATO, "[RPF] {FFFFFF}Odustali ste od kupnje vozila.");
}
}
pawn Код:
case THREAD_UCITAJAUTA:
{
if(szRows)
{
new temp[130];
for(new i = 0; i < szRows; i++)
{
new id;
id = cache_get_field_content_int(i, "ID");
cache_get_field_content(i, "Vlasnik", temp);
format(VInfo[id][Vlasnik], 50, "%s", temp);
VInfo[id][PozX] = cache_get_field_content_int(i, "PozX");
VInfo[id][PozY] = cache_get_field_content_int(i, "PozY");
VInfo[id][PozZ] = cache_get_field_content_int(i, "PozZ");
VInfo[id][PozA] = cache_get_field_content_int(i, "PozA");
VInfo[id][Model] = cache_get_field_content_int(i, "Model");
VInfo[id][Cena] = cache_get_field_content_int(i, "Cena");
VInfo[id][VW] = cache_get_field_content_int(i, "VW");
VInfo[id][Int] = cache_get_field_content_int(i, "Int");
VInfo[id][Zakljucan] = cache_get_field_content_int(i, "Zakljucan");
VInfo[id][Boja1] = cache_get_field_content_int(i, "Boja1");
VInfo[id][Boja2] = cache_get_field_content_int(i, "Boja2");
VInfo[id][ImaVlasnika] = cache_get_field_content_int(i, "ImaVlasnika");
VInfo[id][Novac] = cache_get_field_content_int(i, "Novac");
VInfo[id][Droga] = cache_get_field_content_int(i, "Droga");
VInfo[id][Mats] = cache_get_field_content_int(i, "Mats");
VInfo[id][Oruzje1] = cache_get_field_content_int(i, "Oruzje1");
VInfo[id][Oruzje2] = cache_get_field_content_int(i, "Oruzje2");
VInfo[id][Oruzje3] = cache_get_field_content_int(i, "Oruzje3");
VInfo[id][Municija1] = cache_get_field_content_int(i, "Municija1");
VInfo[id][Municija2] = cache_get_field_content_int(i, "Municija2");
VInfo[id][Municija3] = cache_get_field_content_int(i, "Municija3");
SpawnedAutomobila++;
VInfo[id][ownedvehicle] = CreateVehicle_H(VInfo[id][Model], 11999.0+random(10000), 11999.0+random(10000), 0.0, 0.0, 0, 0, 1000);
}
printf("Roleplay Factory - Server je ucitao %d automobila u vlasnistvu", SpawnedAutomobila);
}
}
pawn Код:
case 8:
{
new a = PI[playerid][Auto];
/*if(GetPlayerVehicleID(playerid) != VInfo[i][ownedvehicle])
{
SCM(playerid, TOMATO, "[RPF] {FFFFFF}Niste u svom vozilu.");
return 1;
}*/
if(IsPlayerInRangeOfPoint(playerid, 5.0, VInfo[i][PozX], VInfo[i][PozY], VInfo[i][PozZ]) || GetPlayerVehicleID(playerid) != VInfo[i][ownedvehicle])
{
if(VInfo[a][Locked] == 0)
{
VInfo[a][Locked] = 1;
GameTextForPlayer(playerid, "~W~Vehicle is ~R~locked", 2500, 6);
new upitu[64];
format(upitu, 64, "UPDATE `Automobili` SET `Zakljucan` = '1' WHERE `ID` = '%d'", a);
mysql_function_query(konekt, upitu, true, "OnQueryFinish", "i", THREAD_OSTALO);
}
else
{
VInfo[a][Locked] = 0;
GameTextForPlayer(playerid, "~W~Vehicle is ~G~unlocked", 2500, 6);
new upitu[64];
format(upitu, 64, "UPDATE `Automobili` SET `Zakljucan` = '0' WHERE `ID` = '%d'", a);
mysql_function_query(konekt, upitu, true, "OnQueryFinish", "i", THREAD_OSTALO);
}
}
else return SCM(playerid, TOMATO, "[RPF] {FFFFFF}Morate biti kod/u vaseg vozila.");
}