Something went wrong. Try again.
Something went wrong. Try again.
1.7 kB · 73 lines
at master
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374void onPlayerRequestSpawn(CRules@ this, CPlayer@ player){ Respawn(this, player, SpawnPos);}
void RespawnAll(Vec2f pos) { for (int i = 0; i < getPlayerCount(); i++) { Respawn(getRules(), getPlayer(i), pos); }}
CBlob@ SpawnBlobWithScript(string &in name, int team, Vec2f &in pos, string[] &in scripts) { CRules@ rules = getRules(); // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA if (!rules.hasCommandID("ASS_SYNC")) { rules.addCommandID("ASS_SYNC"); }
CBlob@ blob = server_CreateBlob(name, team, pos); for (int a = 0; a < scripts.size(); a++) { blob.AddScript(scripts[a]); blob.getSprite().AddScript(scripts[a]); CBitStream p; p.write_netid(blob.getNetworkID()); p.write_string(scripts[a]); rules.SendCommand(rules.getCommandID("ASS_SYNC"), p); }
return @blob;}
void onCommand(CRules@ this, u8 cmd, CBitStream @params) { if (cmd == this.getCommandID("ASS_SYNC") && !isServer() && isClient()) { CBlob@ blob = getBlobByNetworkID(params.read_netid()); string script = params.read_string();
blob.AddScript(script); blob.getSprite().AddScript(script); }}
CBlob@ Respawn(CRules@ this, CPlayer@ player, Vec2f pos){ if (player !is null) { // remove previous players blob CBlob @blob = player.getBlob();
if (blob !is null) { CBlob @blob = player.getBlob(); blob.server_SetPlayer(null); blob.server_Die(); }
CBlob @newBlob = server_CreateBlob("builder", 0, pos); newBlob.server_SetPlayer(player);
newBlob.AddScript("player_flight.as"); if (getMap().get_u8("BOX2D_SUBSTEP") > 0) { newBlob.AddScript("player_explode.as"); } return newBlob; }
return null;}