Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: DewsmokeYT on Aug 02, 2025, 06:36 PM

Title: free countdown timer function in VC:MP Squirrel
Post by: DewsmokeYT on Aug 02, 2025, 06:36 PM
Here's a countdown timer function in VC:MP Squirrel that sends a message every second to all players until it reaches zero, then sends a final alert to each player. It uses NewTimer to call itself every second, and loops through all connected players with GetMaxPlayers and FindPlayer. To start it, just call EbolaCountdown(10);. Here's the code:


function EbolaCountdown(count) {
    if(count > 0) {
        Message("[#FF0000]EBOLA OUTBREAK INCOMING: " + count + " SECONDS");
        NewTimer("EbolaCountdown", 1000, 1, count - 1);
    } else {
        local players = [];
        for(local i = 0; i < GetMaxPlayers(); i++) {
            local player = FindPlayer(i);
            if(player) players.push(player);
        }
        foreach(local player in players) {
            SendPlayerMessage(player, "[#FF0000]Ebola outbreak has started!");
        }
    }
}



also snippet of how ebola might work
        if(players.len() > 0) {
            // Randomly select a victim
            local victim = players[rand() % players.len()];
            victim.Health = 0.0;
           
            // Find the buyer to send them a message
            local buyer = FindPlayer(ebolaBuyer);
            if(buyer) {
                MessagePlayer("[#00FF00]Your Ebola outbreak has killed " + victim.Name + "!", buyer);
            }
           
            Message("[#FF0000]EBOLA OUTBREAK: " + victim.Name + " has been infected and died!");
        }
        ebolaBuyer = null; // Reset the buyer
    }