• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Instant player desync script

Status
Not open for further replies.
Level 8
Joined
Mar 20, 2007
Messages
224
Alright; I want to make a trigger that will instantly desync a player (the victim) from a game.

JASS:
function desyncPlayer takes integer victim returns nothing
    local unit array u
    local integer i = 0
    if GetLocalPlayer() != Player(victim) then
        loop        
        set u[i] = CreateUnit(Player(0), 'h000', 0, 0, 0)
        exitwhen i == victim
        set i = i + 1     
        endloop                
    endif
    set i = 0
    loop
        call RemoveUnit(u[i])
        set u[i] = null        
        exitwhen i == 24
        set i = i + 1
    endloop
endfunction

That's my current script; not very clean, and although it works, it does not work well - it is not instantaneous desync according to my tests.

Can anyone help me write something better and more guaranteed?

(Also, how to check how many human players in a game still there?)
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
To desync a player it would be enough to create one unit for any player, but for everyone but the victim itself. But probably, if you try to create a unit for the victim while the victim himself will not have it created would cause a desync.

By other words, wouldn't this be enough?
JASS:
function desyncPlayer takes integer victim returns nothing
    if GetLocalPlayer() != Player(victim) then
        call RemoveUnit(CreateUnit(Player(victim), 'h000', 0, 0, 0))
    endif
endfunction

If you want to check this in a multiplayer game, add a trigger with the event 'Player leaves the game', and display a message when he is leaving. As an alternative you can always check if the player has left in the allies tab in-game (f11) I think.
 
Status
Not open for further replies.
Top