[Plugin] MultiThread
#61

Hmm... How about use thread for calculates? Example:
pawn Код:
new tickid;
new Float:PlayerVelocity[MAX_PLAYERS][3];
new PlayerSpeed[MAX_PLAYERS];

public OnGameModeInit() {
    tickid = CreateThread("CalculateSpeed");
}

public OnGameModeExit() {
    DestroyThread(tickid);
}

public CalculateSpeed(threadid) {
    for(new i; i < MAX_PLAYERS; i++) {
        PlayerSpeed[i] = floatround(floatsqroot(floatabs(floatpower(PlayerVelocity[i][0] + PlayerVelocity[i][1] + PlayerVelocity[i][2],2))) * 100)
    }
    SleepThread(100);
}

public OnPlayerUpdate(playerid) {
    GetVehicleVelocity(GetPlayerVehicleID(playerid), PlayerVelocity[playerid][0], PlayerVelocity[playerid][1], PlayerVelocity[playerid][2]);
    // Here send to player (PlayerSpeed[playerid])
}
UPD: Server anyway crashes
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)