admin | Дата: Вторник, 11.06.2013, 01:05:45 | Сообщение # 1 |
Группа: Администраторы
Сообщений: 3869
| Всем привет. в этом уроке я вам расскажу как сделать анти-чит машин/тачек с помощью собейта. Вверху мода
Код new Float:VehPos[MAX_VEHICLES][4]; new bool: BanCar[MAX_VEHICLES]; new TimeUpdate[MAX_PLAYERS];
forward UpdateVehiclePos(vehicleid, type);
bool: UseCar(carid); //bool: StopCar(carid); После этого ищем Код public OnVehicleStreamIn и туда вставляем Код UpdateVehiclePos(vehicleid, 0); примерно так должен быть public OnVehicleStreamIn Код public OnVehicleStreamIn(vehicleid, forplayerid) { UpdateVehiclePos(vehicleid, 0); return 1; } После этого ищем Код public OnPlayerStateChange и туда вставляем: Код if(newstate == PLAYER_STATE_DRIVER) SetPVarInt(playerid,"VehID",GetPlayerVehicleID(playerid)); if(oldstate == PLAYER_STATE_DRIVER) { if(BanCar[GetPVarInt(playerid,"VehID")]) KillTimer(TimeUpdate[playerid]); TimeUpdate[playerid] = SetTimerEx("UpdateVehiclePos", 10000, false, "ii", GetPVarInt(playerid,"VehID"), 1); BanCar[GetPVarInt(playerid,"VehID")] = true; } Примерно так должен быть Код public OnPlayerStateChange
Код public OnPlayerStateChange(playerid, newstate, oldstate) { if(newstate == PLAYER_STATE_DRIVER) SetPVarInt(playerid,"VehID",GetPlayerVehicleID(playerid)); if(oldstate == PLAYER_STATE_DRIVER) { if(BanCar[GetPVarInt(playerid,"VehID")]) KillTimer(TimeUpdate[playerid]); TimeUpdate[playerid] = SetTimerEx("UpdateVehiclePos", 10000, false, "ii", GetPVarInt(playerid,"VehID"), 1); BanCar[GetPVarInt(playerid,"VehID")] = true; } return 1; }
После этого в любое место вставляем функции: Код public UpdateVehiclePos(vehicleid, type) { if(type == 1) { /*if(!StopCar(vehicleid)) { SetTimerEx("UpdateVehiclePos", 10000, false, "ii", vehicleid, 1); return 1; }*/ BanCar[vehicleid] = false; } GetVehiclePos(vehicleid, VehPos[vehicleid][0], VehPos[vehicleid][1], VehPos[vehicleid][2]); GetVehicleZAngle(vehicleid, VehPos[vehicleid][3]); return 1; }
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat) { new Float:Pos[3]; GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]); new Float:Count[2]; Count[0] = Difference(Pos[0],VehPos[vehicleid][0]); Count[1] = Difference(Pos[1],VehPos[vehicleid][1]); switch(GetVehicleModel(vehicleid)) { case 435, 450, 584, 591, 606..608, 610..611: goto UPDATE; } if((Count[0] > 5 || Count[1] > 5) && !UseCar(vehicleid) && !BanCar[vehicleid]) { SetVehiclePos(vehicleid, VehPos[vehicleid][0], VehPos[vehicleid][1], VehPos[vehicleid][2]); SetVehicleZAngle(vehicleid, VehPos[vehicleid][3]); } else { UPDATE: UpdateVehiclePos(vehicleid, 0); } return 1; }
stock Difference(Float:Value1, Float:Value2) { return floatround((Value1 > Value2) ? (Value1 - Value2) : (Value2 - Value1)); }
stock bool: UseCar(carid) { for(new i; i != GetMaxPlayers(); i++) { if(!IsPlayerConnected(i)) continue; if(IsPlayerInVehicle(i, carid)) return true; } return false; }
stock SetVehiclePosition(vehicleid, Float:X, Float:Y, Float:Z) { SetVehiclePos(vehicleid ,X,Y,Z); UpdateVehiclePos(vehicleid, 0); }
/*stock bool: StopCar(carid) { new Float:Pos[3]; GetVehicleVelocity(carid, Pos[0], Pos[1], Pos[2]); if(Pos[0] == 0.0 && Pos[1] == 0.0 && Pos[2] == 0.0) return true; return false; }*/ Автор:Games
zm-jail.ru Разработка сайта samp-pawno.ru
|
|
|
|