16.10.2013, 18:39
Well, I'm trying to create a Roleplay server, and now I'm doing the car dealership.
Method for the server to load the car:
And then programmed for when the player enters the car, if the variable iPlayerInfo [playerid] [Chave1] key (1,2 or 3) was equal to iCarInfo [Car] [cID] the player could stay in the car, otherwise would be expelled.
PS: Chave == Key in english
Then, OnPlayerStateChange
PS: variable arroz was created to reduce the "visual" size of the variable.
But it simply did not work.
He said that the car was not mine, and ejectava me.
Then I tried something else. Go to /dl and change the key for id "real" car. It worked perfectly!
I wanted to handle that "real" id that appears in the / dl. Someone?
OBS:
My load cars function:
Thank you everybody!
****** translator sucks
Method for the server to load the car:
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);
PS: Chave == Key in english
Then, 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, "This car is yours.");
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
But it simply did not work.
He said that the car was not mine, and ejectava me.
Then I tried something else. Go to /dl and change the key for id "real" car. It worked perfectly!
I wanted to handle that "real" id that appears in the / dl. Someone?
OBS:
My load cars function:
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");
}
****** translator sucks