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, "Vocк jб tem um carro");
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", 1);
dini_Set(string, "Dono", aname);
SendClientMessage(playerid, Violeta, "(BDL) Parabens Voce adquiriu um Veiculo!");
SendClientMessage(playerid, Vermelho, "(INFO) Para ver os comandos do 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;
}
}
}
}
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"), "Nenhum", true) == 0){ // "Nenhum" й o que tem em carroID em caso de nгo tiver dono. No arquivo ini nй
SendClientMessage(playerid, Vermelho, "Carro tem dono");
return 1;
}
if(strcmp(dini_Get(string, "Dono"), pname, true) == 0){
SendClientMessage(playerid, Vermelho, "Vocк jб tem um carro");
return 1;
}
i
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", 1);
dini_Set(string, "Dono", aname);
SendClientMessage(playerid, Violeta, "(BDL) Parabens Voce adquiriu um Veiculo!");
SendClientMessage(playerid, Vermelho, "(INFO) Para ver os comandos do 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;
}
}
}
}
|
Nao funfou, Comprou do mesmo jeito. Assim vou falar melhor sobre essa duvida Por exemplo. Meu servidor e RPG, nele tem o comando /comprarcarro. Quando uma pessoa compra um carro, tudo bem. Ai vem outra pessoa entra no carro ai aparece "Este Carro nгo e seu e de %s"e etc. Ao aparecer isso o player sai do carro automaticamente, e ai quando ele estiver saindo do carro ele simplesmente da /comprarcarro, e pronto ele comprou o carro :S |
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, " - Este carro й seu, seja bem vindo !");
} else {
format(string, sizeof(string), "[BDL] - » Este carro nгo й seu, й de: %s «", dini_Get(string, "Dono"));
SendClientMessage(playerid, 0x9E3EFFAA, string);
format(string, sizeof(string), "[BDL] - » %s Tentou Robar um Carro e foi colocado na Lista de Procurados.«!",pname);
SendClientMessageToAll(Amarelo, string);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
//SetPlayerPos(playerid, X, Y, Z +1);
Procurados[playerid]= 1;
SetPlayerWantedLevel(playerid, 6);
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), " - ALARME: %s(Id:%d) tentou roubar seu carro.", pname, playerid);
SendClientMessage(i, tcadm, string);
}
}
}
RemovePlayerFromVehicle(playerid);
}
} else {
format(string, sizeof(string), " - 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);
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(dini_Int(string, "TDono") == 1) {
SendClientMessage(playerid, Vermelho, "Carro tem dono");
return 1;
}
if(strcmp(dini_Get(string, "Dono"), pname, true) == 0){
SendClientMessage(playerid, Vermelho, "Vocк jб tem um carro");
return 1;
}
i
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", 1);
dini_Set(string, "Dono", aname);
SendClientMessage(playerid, Violeta, "(BDL) Parabens Voce adquiriu um Veiculo!");
SendClientMessage(playerid, Vermelho, "(INFO) Para ver os comandos do 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;
}
}
}
}
if(strcmp(dini_Get(string, "Dono"), pname, true) == 0){
SendClientMessage(playerid, Vermelho, "Vocк jб tem um carro");
return 1;
}
dini_IntSet(string, "TDono", 1);