04.03.2014, 04:10
O erro continua. O player compra o carro, e quando sai dele, o carro jб estб a venda novamente. O player jб nгo й mais o dono. O dono dos veнculos nгo salvam.
Alguns cуdigos relacionados:
Alguns cуdigos relacionados:
PHP код:
new string[256];
format(string, sizeof(string), "carro%d.ini", proximocarro);
new carroid;
carroid = AddStaticVehicle(m, x, y, z, r, c, d);
dini_IntSet(string, "Id", carroid);
proximocarro++;
}
PHP код:
new string[256];
for(new carro = 5; carro < MAX_CARROS; carro++)
{
format(string, sizeof(string), "carro%d.ini", carro);
if(dini_Exists(string))
{
new carroid;
carroid = AddStaticVehicle(dini_Int(string, "Modelo"), dini_Float(string, "CordX"), dini_Float(string, "CordY"), dini_Float(string, "CordZ"), dini_Float(string, "Angulo"), dini_Int(string, "Cor1"), dini_Int(string, "Cor2"));
dini_IntSet(string, "Id", carroid);
proximocarro++;
}
}
PHP код:
if(strcmp(cmd, "/liberarcarro", true) == 0)
{
new preco;
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, Vermelho, "/liberarcarro [carroID]");
return 1;
}
preco = strval(tmp);
format(string, sizeof(string), "carro%d.ini", preco);
if(dini_Exists(string))
{
if(pAdmin[playerid] >= 5)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
dini_IntSet(file2, "Carro", 0);
dini_IntSet(string, "TDono", 0);
dini_Set(string, "Dono", "Nenhum");
format(string, sizeof(string), "[NH] O administrador %s liberou o veiculo %d", pname,preco);
SendClientMessageToAll(tcadm, string);
SendClientMessage(playerid, tcadm, "(ATКNЗГO) O player que era dono deste carro, ficarб bugado! Sem poder comprar outro carro.");
SendClientMessage(playerid, tcadm, "(ATКNЗГO) Para retirar este erro, quando o player logar digite /removercarro [ID]");
return 1;
}
else
{
SendClientMessage(playerid, Vermelho, "[ERRO] Vocк nгo tem permissгo.");
}
}
return 1;
}
PHP код:
if(strcmp(cmd, "/carro", true) == 0)
{
new preco;
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, Vermelho, "/carro [carroID]");
return 1;
}
preco = strval(tmp);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "carro%d.ini", preco);
if(dini_Exists(string))
{
format(STRX, sizeof(STRX), "Id[%d] Dono[%s] Preзo[R$%d] Modelo[%s]", preco, dini_Get(string, "Dono"), dini_Int(string, "Preco"), PlayerVehicle[(GetVehicleModel(dini_Int(string, "Int")))-400]);
SendClientMessage(playerid, Amarelo, STRX);
}
return 1;
}
PHP код:
if(strcmp(cmd, "/ccar", true) == 0)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
if(IsPlayerAdmin(playerid)|| pAdmin[playerid] == 5)
{
new tmp[256];
new carid, Float:ang, preco, cor1, cor2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, Cinza, "[ERRO] Veiculo invбlido.");
return 1;
}
carid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, Cinza, "[ERRO]: /ccar [id] [preзo] [cor1] [cor2]");
return 1;
}
preco = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, Cinza, "[ERRO]: /ccar [id] [preзo] [cor1] [cor2]");
return 1;
}
cor1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, Cinza, "[ERRO]: /ccar [id] [preзo] [cor1] [cor2]");
return 1;
}
cor2 = strval(tmp);
if(carid >= 400 && carid <= 611)
{
if(IsPlayerInAnyVehicle(playerid))
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
GetVehicleZAngle(GetPlayerVehicleID(playerid),ang);
format(string, sizeof(string), "carro%d.ini", proximocarro);
if(!dini_Exists(string))
{
dini_Create(string);
dini_IntSet(string, "Modelo", carid);
dini_FloatSet(string, "CordX", Float:X);
dini_FloatSet(string, "CordY", Float:Y);
dini_FloatSet(string, "CordZ", Float:Z);
dini_FloatSet(string, "Angulo", Float:ang);
dini_IntSet(string, "Cor1", cor1);
dini_IntSet(string, "Cor2", cor2);
dini_IntSet(string, "TDono", 0);
dini_Set(string, "Dono", "Ninguem");
dini_IntSet(string, "Preco", preco);
}
SetTimerEx("CriarVeiculo2",5000,false,"dffffdd",carid,X,Y,Z,ang,cor1,cor2);
format(string, sizeof(string), "[NH] Veiculo criado com sucesso!");
SendClientMessage(playerid, Azul, string);
return 1;
}
else
{
SendClientMessage(playerid, Vermelho, "[ERRO] Vocк nгo estб em um veiculo!");
}
}
else
{
SendClientMessage(playerid, Cinza, "[ERRO] Veiculo invбlido.");
return 1;
}
}
else
{
SendClientMessage(playerid, Cinza, "[ERRO] Vocк nгo tem permissгo para isso");
return 1;
}
}
PHP код:
if(strcmp(cmdtext, "/comprarcarro", true) == 0)
{
new VehicleID;
VehicleID = GetPlayerVehicleID(playerid);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
for(new carro = 0; carro < MAX_CARROS; carro++) {
format(string, sizeof(string), "carro%d.ini", carro);
if(strcmp(dini_Get(string, "Dono"), pname, true) == 0) {
SendClientMessage(playerid, Vermelho, "[ERRO] Vocк jб tem um veiculo e nгo pode comprar outro.");
return 1;
}
if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleSeat(playerid) == 0 && VehicleID == dini_Int(string, "Id")) {
if(GetPlayerGrana(playerid) >= dini_Int(string, "Preco")) {
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
dini_IntSet(string, "TDono", 5);
dini_Set(string, "Dono", aname);
SendClientMessage(playerid, -1, "[NH] Veiculo comprado com sucesso!");
SendClientMessage(playerid, -1, "[NH] Para ver as funзхes de seu veiculo, Use: '/meucarro'.");
GivePlayerGrana(playerid, -dini_Int(string, "Preco"));
TogglePlayerControllable(playerid, 1);
return 1;
}
else {
SendClientMessage(playerid, Vermelho, "[ERRO] Vocк nгo tem dinheiro suficiente!");
return 1;
}
}
}
}
PHP код:
for(new c = 0; c < MAX_CARROS; c++)
{
format(string, sizeof(string), "carro%d.ini", c);
if(strcmp(dini_Get(string, "Dono"), aname, false) == 0)
{
dini_Set(string, "Dono", inputtext);
}
PHP код:
if(newstate == PLAYER_STATE_DRIVER)
{
new string[256];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
for(new carro = 0; carro < MAX_CARROS; carro++)
{
new vid;
vid = GetPlayerVehicleID(playerid);
format(string, sizeof(string), "carro%d.ini", carro);
if(dini_Exists(string)){
if(vid == dini_Int(string, "Id")){
if(dini_Int(string, "TDono") == 1){
if(strcmp(dini_Get(string, "Dono"), pname, true) == 0){
SendClientMessage(playerid, Azul, "[NH] Este carro й seu, seja bem vindo !");
} else {
format(string, sizeof(string), "[NH] Este carro nгo й seu, й de: %s", dini_Get(string, "Dono"));
SendClientMessage(playerid, Azul, string);
for(new i=0; i<MAX_PLAYERS; i++){
if(IsPlayerConnected(i)){
new nome[MAX_PLAYER_NAME];
GetPlayerName(i, nome, sizeof(nome));
if(strcmp(dini_Get(string, "Dono"), nome, true) == 0 && GetPlayerVehicleID(playerid) == dini_Int(string, "Id")){
format(string, sizeof(string), "[NH] ALARME: %s(Id:%d) tentou roubar seu carro.", pname, playerid);
SendClientMessage(i, tcadm, string);
}
}
}
RemovePlayerFromVehicle(playerid);
}
} else {
format(string, sizeof(string), "[NH] Este carro estб a venda ! Preзo: %d reais, use /comprarcarro", dini_Int(string, "Preco"));
SendClientMessage(playerid, Amarelo, string);
SendClientMessage(playerid, Vermelho, "Para sair do carro aperte F.");
incar[playerid] = 1;
TogglePlayerControllable(playerid, 0);
}
}
}
}
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
format(file, sizeof(file), PASTA_CONTAS, aname);
new modelo = GetVehicleModel(GetPlayerVehicleID(playerid));
new vid = GetPlayerVehicleID(playerid);