18.04.2014, 15:48
com faзo para que quando o player que crio os carros que estao espalhados sai do servidor e os carros somem,pois os carros de players que ainda nao sairam estao sumindo quando outro player sai do server! codigo abaixo!
pawn Код:
if(strcmp(cmd, "/car", true) == 0)
{
new tmp2[256], tmp3[256]; tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx); tmp3 = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "{FF0000}Uso correto: /Car nome");
new car, colour1, colour2;
if(!IsNumeric(tmp)) car = GetVehicleModelIDFromName(tmp); else car = strval(tmp);
if(car < 400 || car > 611) return SendClientMessage(playerid, red, "ERRO: Modelo de Veнculo Invбlido");
if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
if(MundoMATAMATA[playerid] == false)
{
if(car == 520 || car == 432 || car == 592 || car == 425 || car == 464|| car == 476|| car == 447) return SendClientMessage(playerid, CorCinza, "Veнculo liberado somente no mundo Mata Mata {FFFFFF}/Mundos {FFFFFF}!");
}
new LVehicleID,Float:X,Float:Y,Float:Z, Float:Angle,int1; GetPlayerPos(playerid, X,Y,Z); GetPlayerFacingAngle(playerid,Angle); int1 = GetPlayerInterior(playerid);
if(IsPlayerInAnyVehicle(playerid)) {
DestroyVehicle(GetPlayerVehicleID(playerid));
LVehicleID = CreateVehicle(car, X,Y,Z, Angle, colour1, colour2, -1); LinkVehicleToInterior(LVehicleID,int1);
SetVehicleVirtualWorld(LVehicleID ,GetPlayerVirtualWorld(playerid));
PutPlayerInVehicle(playerid,LVehicleID, 0);
format(string, sizeof(string), "{FFFFFF}Seu Veнculo foi criado com sucesso!{00F600} \"{FFFFFF}%s{00F600}\" (Modelo: {FFFFFF}%d{00F600}) (Cores: {FFFFFF}%d / %d{00F600})", VehicleNames[car-400], car, colour1, colour2);
SendClientMessage(playerid, AMARELO, string);
return 1;
} else {
LVehicleID = CreateVehicle(car, X,Y,Z, Angle, colour1, colour2, -1); LinkVehicleToInterior(LVehicleID,int1);
PlayerInfo[playerid] = LVehicleID;
SetVehicleVirtualWorld(LVehicleID,GetPlayerVirtualWorld(playerid));
PutPlayerInVehicle(playerid,LVehicleID, 0);
format(string, sizeof(string), "{FFFFFF}Seu Veнculo foi criado com sucesso!{00F600} \"{FFFFFF}%s{00F600}\" (Modelo: {FFFFFF}%d{00F600}) (Cores: {FFFFFF}%d / %d{00F600})", VehicleNames[car-400], car, colour1, colour2);
SendClientMessage(playerid, AMARELO, string);
return 1;
}
}
pawn Код:
//=============================[ RESPAWN AUTOMATICO ]===============================
forward RespawnVeh();
public RespawnVeh()
{
new bool:vehicle[MAX_VEHICLES];
for(new j = 1; GetVehicleModel(j); ++j)
{
vehicle[j] = false;
for(new i, p = GetMaxPlayers(); i < p; ++i)
{
if(!IsPlayerInAnyVehicle(i) || !IsPlayerConnected(i)) continue;
if(IsPlayerInVehicle(i, j))
{
vehicle[j] = true;
break;
}
}
if(!vehicle[j]) DestroyVehicle(j);
}
return 1;
}
//=============================[ RESPAWN AUTOMATICO ]===============================
forward VehRes(vehicleid);
public VehRes(vehicleid)
{
DestroyVehicle(vehicleid);
}