09.02.2010, 07:15
new bool:VehicleInUse[MAX_VEHICLES];
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
VehicleInUse[vehicleid] = true;
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
VehicleInUse[vehicleid] = false;
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate == PLAYER_STATE_DRIVER) {
VehicleInUse[GetPlayerVehicleID(playerid)] = true;
}
if(oldstate == PLAYER_STATE_DRIVER) {
VehicleInUse[GetPlayerVehicleID(playerid)] = false;
}
return 1;
}
stock SetVehicleModel(m,model) {
new vehid = GetPlayerVehicleID(m);
new Float:fx[7];
if (RaceStart==1 && RaceParticipant[m]==4 && GetPlayerState(m)!=PLAYER_STATE_PASSENGER) {
fx[0] = PF[m], fx[1] = QF[m], fx[2] = RF[m];
fx[3] = RAngle[m], fx[4] = VX[m], fx[5] = VY[m], fx[6] = VZ[m];
} else {
if (IsPlayerInAnyVehicle(m)) {
GetVehiclePos(vehid,fx[0],fx[1],fx[2]);
GetVehicleZAngle(vehid,fx[3]);
GetVehicleVelocity(vehid,fx[4],fx[5],fx[6]);
} else {
GetPlayerPos(m,fx[0],fx[1],fx[2]);
GetPlayerFacingAngle(m,fx[3]);
GetPlayerVelocity(m,fx[4],fx[5],fx[6]);
}
}
if ((GetVehicleModel(vehid) == model) || (model == 0)) return 1;
if (model == 999) { RemovePlayerFromVehicle(m); DestroyVehicle(vehid); return 1; }
if (IsPlayerInAnyVehicle(m)) RemovePlayerFromVehicle(m), DestroyVehicle(vehid);
for (new i=0;i < MAX_VEHICLES;i++) {
if (GetVehicleModel(i) == model && VehicleInUse[i] == false) {
SetVehiclePos(i,fx[0],fx[1],fx[2]);
//SendClientMessage(m,COLOR_RED,"íàøëè òà÷êó ñàæàåì");
PutPlayerInVehicle(m,i,0);
SetVehicleZAngle(i,fx[3]);
SetVehicleVelocity(i,fx[4],fx[5],fx[6]);
return 1;
}
}
vehid = CreateVehicle(model,fx[0],fx[1],fx[2],fx[3],1,1,1000);
PutPlayerInVehicle(m,vehid,0);
SetVehicleZAngle(vehid,fx[3]);
SetVehicleVelocity(vehid,fx[4],fx[5],fx[6]);
//SendClientMessage(m,COLOR_RED,"íå íàøëè òà÷êó ñîçäà¸ì");
return 1;
}
вроде бы vehicleinuse должна быть на 100% правильно настроена, однако всё равнотупит....
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
VehicleInUse[vehicleid] = true;
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
VehicleInUse[vehicleid] = false;
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate == PLAYER_STATE_DRIVER) {
VehicleInUse[GetPlayerVehicleID(playerid)] = true;
}
if(oldstate == PLAYER_STATE_DRIVER) {
VehicleInUse[GetPlayerVehicleID(playerid)] = false;
}
return 1;
}
stock SetVehicleModel(m,model) {
new vehid = GetPlayerVehicleID(m);
new Float:fx[7];
if (RaceStart==1 && RaceParticipant[m]==4 && GetPlayerState(m)!=PLAYER_STATE_PASSENGER) {
fx[0] = PF[m], fx[1] = QF[m], fx[2] = RF[m];
fx[3] = RAngle[m], fx[4] = VX[m], fx[5] = VY[m], fx[6] = VZ[m];
} else {
if (IsPlayerInAnyVehicle(m)) {
GetVehiclePos(vehid,fx[0],fx[1],fx[2]);
GetVehicleZAngle(vehid,fx[3]);
GetVehicleVelocity(vehid,fx[4],fx[5],fx[6]);
} else {
GetPlayerPos(m,fx[0],fx[1],fx[2]);
GetPlayerFacingAngle(m,fx[3]);
GetPlayerVelocity(m,fx[4],fx[5],fx[6]);
}
}
if ((GetVehicleModel(vehid) == model) || (model == 0)) return 1;
if (model == 999) { RemovePlayerFromVehicle(m); DestroyVehicle(vehid); return 1; }
if (IsPlayerInAnyVehicle(m)) RemovePlayerFromVehicle(m), DestroyVehicle(vehid);
for (new i=0;i < MAX_VEHICLES;i++) {
if (GetVehicleModel(i) == model && VehicleInUse[i] == false) {
SetVehiclePos(i,fx[0],fx[1],fx[2]);
//SendClientMessage(m,COLOR_RED,"íàøëè òà÷êó ñàæàåì");
PutPlayerInVehicle(m,i,0);
SetVehicleZAngle(i,fx[3]);
SetVehicleVelocity(i,fx[4],fx[5],fx[6]);
return 1;
}
}
vehid = CreateVehicle(model,fx[0],fx[1],fx[2],fx[3],1,1,1000);
PutPlayerInVehicle(m,vehid,0);
SetVehicleZAngle(vehid,fx[3]);
SetVehicleVelocity(vehid,fx[4],fx[5],fx[6]);
//SendClientMessage(m,COLOR_RED,"íå íàøëè òà÷êó ñîçäà¸ì");
return 1;
}
вроде бы vehicleinuse должна быть на 100% правильно настроена, однако всё равнотупит....