Manipular dado -
bruxo00 - 15.10.2013
Bem, estou a tentar criar um servidor de Roleplay, e agora estou a fazer a concessionбria.
Mйtodo de o servidor carregar o carro:
PHP код:
iCarInfo[i][cID] = CreateVehicle(iCarInfo[i][cModel], iCarInfo[i][cX], iCarInfo[i][cY], iCarInfo[i][cZ], iCarInfo[i][cAngle], iCarInfo[i][cCor1], iCarInfo[i][cCor2], 0);
E aн, programei para, quando o jogador entra no carro, se a variбvel
iPlayerInfo[playerid][Chave1] (chave 1,2 ou 3) fosse igual ao
iCarInfo[carro][cID] o jogador conseguia ficar no carro, caso contrбrio, seria expulso.
Aн, no
OnPlayerStateChange
PHP код:
new carro = GetPlayerVehicleID(playerid);
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
new arroz;
arroz = iCarInfo[carro][cID];
if(arroz == iPlayerInfo[playerid][Chave1] || arroz == iPlayerInfo[playerid][Chave2] || arroz == iPlayerInfo[playerid][Chave3] || arroz == iPlayerInfo[playerid][Chave4] || arroz == iPlayerInfo[playerid][ChaveEmp1] || arroz == iPlayerInfo[playerid][ChaveEmp2] || arroz == iPlayerInfo[playerid][ChaveEmp3])
{
SendClientMessage(playerid, -1, "Este carro й teu");
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
PS: a variбvel arroz foi para encortar a variбvel iCarInfo[carro][cID];
Mas, simplesmente, nгo funcionou.
Dizia que o carro nгo era meu, e ejectava-me.
Aн tentei outra coisa. Ir no
/dl e alterar a chave para o id "real" do carro. Funcionou perfeitamente!
Alguйm sabe como manipular aquele ID ou como resolver para funcionar com a variбvel
cID?
Re: Manipular dado -
zSuYaNw - 15.10.2013
pawn Код:
new carro = GetPlayerVehicleID(playerid);
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
new arroz;
arroz = iCarInfo[carro][cID]; printf("Feijao- %d", arroz);
if(arroz == iPlayerInfo[playerid][Chave1] || arroz == iPlayerInfo[playerid][Chave2] || arroz == iPlayerInfo[playerid][Chave3] || arroz == iPlayerInfo[playerid][Chave4] || arroz == iPlayerInfo[playerid][ChaveEmp1] || arroz == iPlayerInfo[playerid][ChaveEmp2] || arroz == iPlayerInfo[playerid][ChaveEmp3])
{
SendClientMessage(playerid, -1, "Este carro й teu");
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
Faz debug, vamos ver se tem valor a variбvel
Re: Manipular dado -
bruxo00 - 15.10.2013
Fiz debug, a variбvel tem o valor daquele ID no
/dl... :3
@ Edit
LOL, sу reparei que vc estava a fazer debug ao arroz...
@ Edit
Tem o mesmo valor que a variбvel
carro...
Re: Manipular dado -
zSuYaNw - 15.10.2013
Код:
printf("Feijao- %d, Chave: %d, %d, %d, %d", arroz, iPlayerInfo[playerid][Chave2], iPlayerInfo[playerid][Chave1], iPlayerInfo[playerid][Chave2], iPlayerInfo[playerid][Chave3], iPlayerInfo[playerid][Chave4]);
Re: Manipular dado -
bruxo00 - 15.10.2013
Onde estб a novidade aн??
Sem eu interferir nos ficheiros dos carros, nгo ia funcionar. Pois o
cID iria ser
12, a minha
Chave1 iria ser
154, logo, nгo ia funcionar.
Eu queria maneira de colocar o id "real" como 154.
Re: Manipular dado -
zSuYaNw - 15.10.2013
quero ver os reais valores que estгo armazenando...
Na compra: identificar variбvel vazia (das chaves й claro) e setar para o id do veнculo.
E em cada arquivo, o nome do veнculo em questгo deverб ser "id_do_carro.ini"
Faзa um loop para carregб-los.
Re: Manipular dado -
bruxo00 - 15.10.2013
Estгo aqui:
PHP код:
[21:35:04] Feijao- 12 (arroz), Chave: 12(chave1), 12(chave2), 12(chave3)
Fiz umas alteraзхes no debug, tinha variбveis repetidas. PS: Eu pus as chaves todas a 12 para testar uma coisa.
Й exactamente assim que tenho a carregar os carros.
Neste momento, estou a testar se as chaves nгo bugam e funcionam. Ainda nгo fiz o sistema de compra.
Carregamento dos carros:
pawn Код:
public CarregarCarros()
{
new ficheiro[64];
for(new i = 0; i < MAX_CARROS; i++)
{
format(ficheiro, sizeof(ficheiro), "iRP/Carros/%d.ini", i);
if(!DOF2_FileExists(ficheiro))
{
if(i == 0) continue;
DOF2_CreateFile(ficheiro);
DOF2_SetInt(ficheiro, "cX", 0);
DOF2_SetInt(ficheiro, "cY", 0);
DOF2_SetInt(ficheiro, "cZ", 0);
DOF2_SetInt(ficheiro, "cAngle", 0);
DOF2_SetInt(ficheiro, "cID", i);
DOF2_SetInt(ficheiro, "cModel", 0);
DOF2_SetInt(ficheiro, "cCor1", 0);
DOF2_SetInt(ficheiro, "cCor2", 0);
DOF2_SetInt(ficheiro, "cChave", i);
DOF2_SaveFile();
}
else
{
iCarInfo[i][cX] = DOF2_GetInt(ficheiro, "cX");
iCarInfo[i][cY] = DOF2_GetInt(ficheiro, "cY");
iCarInfo[i][cZ] = DOF2_GetInt(ficheiro, "cZ");
iCarInfo[i][cAngle] = DOF2_GetInt(ficheiro, "cAngle");
iCarInfo[i][cID] = DOF2_GetInt(ficheiro, "cID");
iCarInfo[i][cModel] = DOF2_GetInt(ficheiro, "cModel");
iCarInfo[i][cCor1] = DOF2_GetInt(ficheiro, "cCor1");
iCarInfo[i][cCor2] = DOF2_GetInt(ficheiro, "cCor2");
iCarInfo[i][cChave] = DOF2_GetInt(ficheiro, "cChave");
if(iCarInfo[i][cX] != 0 && iCarInfo[i][cY] != 0 && iCarInfo[i][cZ] != 0 && iCarInfo[i][cID] != 0)
{
iCarInfo[i][cID] = CreateVehicle(iCarInfo[i][cModel], iCarInfo[i][cX], iCarInfo[i][cY], iCarInfo[i][cZ], iCarInfo[i][cAngle], iCarInfo[i][cCor1], iCarInfo[i][cCor2], 0);
printf("\n Carro n %d carregado com sucesso!\n", i);
}
}
}
printf("\nCarros carregados com sucesso!\n");
}
Re: Manipular dado -
bruxo00 - 16.10.2013
BUMP =)
Re: Manipular dado -
bruxo00 - 18.10.2013
BUMP denovo.
Na board griga pedia ajuda, e ajudaram um pouco, mas ainda nгo consigo fazer isto funcionar... primeira vez que uso um loop deste tipo...
pawn Код:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
new arroz = INVALID_VEHICLE_ID;
new carro = GetPlayerVehicleID(playerid);
for(new i = 0; i != sizeof(iCarInfo); ++i)
{
if(iCarInfo[i][cID] == carro)
{
arroz = carro;
break;
}
}
//if(arroz == iPlayerInfo[playerid][Chave1] || arroz == iPlayerInfo[playerid][Chave2] || arroz == iPlayerInfo[playerid][Chave3] || arroz == iPlayerInfo[playerid][Chave4] || arroz == iPlayerInfo[playerid][ChaveEmp1] || arroz == iPlayerInfo[playerid][ChaveEmp2] || arroz == iPlayerInfo[playerid][ChaveEmp3])
if(arroz == INVALID_VEHICLE_ID)
{
RemovePlayerFromVehicle(playerid);
}
else
{
SendClientMessage(playerid, -1, "Este carro й teu");
}
}
Agora, mesmo que a
cChave seja diferente do
cID, diz que o carro й meu na mesma...
Alguйm?