15.08.2012, 22:47
Here is the code of OnPlayerDeath
And here is the code of OnPlayerSpawn
Код:
public OnPlayerDeath(playerid, killerid, reason) { HideAllTextDraws(playerid); new str[128]; Spawned[playerid] = 0; Spree[playerid] = 0; Spree[killerid]++; if(GetPlayerWantedLevel(playerid) > 0) SetPlayerWantedLevel(playerid,0); if(killerid == INVALID_PLAYER_ID) { SendDeathMessage(INVALID_PLAYER_ID,playerid,reason); GameTextForPlayer(playerid,"~r~WASTED",4000,1); } else { SendDeathMessage(killerid,playerid,reason); // ========== High Score ======= if(GetPlayerScore(killerid) == 25 || GetPlayerScore(killerid) == 50 || GetPlayerScore(killerid) == 75) { GetPlayerName(killerid, str, sizeof(str) ); SendClientMessageToAll(COLOR_RED,"____________________________"); format(str, sizeof(str), ">> OWNING ! [%s] has %d Kills", str, GetPlayerScore(killerid) ); SendClientMessageToAll(GetPlayerColor(killerid), str); } else if(GetPlayerScore(killerid) == 100 || GetPlayerScore(killerid) == 150 || GetPlayerScore(killerid) == 200) { GetPlayerName(killerid, str, sizeof(str) ); SendClientMessageToAll(COLOR_RED,"_____________________________________"); format(str, sizeof(str), ">> LEGEND >> ! [%s] has %d Kills", str, GetPlayerScore(killerid)); SendClientMessageToAll(GetPlayerColor(killerid), str); SendClientMessageToAll(COLOR_RED,"_____________________________________"); } // ========== killing Spree ===== if(Spree[killerid] == 5 || Spree[killerid] == 10 || Spree[killerid] == 15 || Spree[killerid] == 20 || Spree[killerid] == 25) { GetPlayerName(killerid, str, sizeof(str) ); SendClientMessageToAll(COLOR_RED,"____________________________"); format(str, sizeof(str), ">> KILLING SPREE ! [%s] has %d Kills in a row", str, Spree[killerid] ); SendClientMessageToAll(GetPlayerColor(killerid), str); SetPlayerWantedLevel(playerid, Spree[killerid] / 5); } // ========== bounties ========= if(bounty[playerid] > 0) { GetPlayerName(playerid, str, sizeof(str)); format(str, sizeof(str), "You earned a bounty of %d for killing %s.", bounty[playerid], str); SendClientMessage(killerid, COLOR_GREEN, str); GivePlayerMoney(killerid, bounty[playerid]); bounty[playerid] = 0; } // ========== gang zones ======= if(gTeam[killerid] != gTeam[playerid]) { new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z); for(new zone = 0; zone < MAX_ZONES; zone++) { if(x >= ZoneLocations[zone][0] && x < ZoneLocations[zone][2] && y >= ZoneLocations[zone][1] && y < ZoneLocations[zone][3]) { // The Killer who kills on his own turf if( ZoneInfo[ zone ][ZoneOwnerID] == gTeam[killerid] ) { if(ZoneInfo[zone][GangWarInProgress] == 1) { if(gTeam[playerid] == ZoneInfo[zone][ZoneAttackers]) GangInfo[ gTeam[killerid] ][DefendCount]++; if( GangInfo[ gTeam[killerid] ][DefendCount] == GANGAREA_DEFEND ) { // send the message GetPlayerName(killerid, str, sizeof(str)); SendClientMessageToAll(COLOR_RED," "); format(str, sizeof(str), "*** GangZone Message: %s from %s has DEFENDED his Turf from %s", str,GangInfo[ gTeam[killerid] ][GangName], GangInfo[ gTeam[playerid] ][GangName] ); SendClientMessageToAll(GetPlayerColor(killerid), str); SendClientMessageToAll(COLOR_RED," "); // change the zone colour GangZoneStopFlashForAll( zone ); GangZoneHideForAll( zone ); GangZoneShowForAll( zone, GetPlayerColor(killerid) ); // reset the counters GangInfo[ gTeam[killerid] ][UnderAttackCount] = 0; GangInfo[ gTeam[playerid] ][UnderAttackCount] = 0; GangInfo[ gTeam[killerid] ][DefendCount] = 0; ZoneInfo[zone][GangWarInProgress] = 0; ZoneInfo[zone][ZoneAttackers] = -1; // save the current zone colour for new players to see DONT REALLY NEED ALL THIS AGAIN GangZone_CurrentColour[ zone ] = GetPlayerColor(killerid); // save the 'new' owner of the zone strmid(ZoneInfo[ zone ][ZoneOwner], GangInfo[ gTeam[killerid] ][GangName], 0, strlen(GangInfo[ gTeam[killerid] ][GangName]), MAX_PLAYER_NAME); ZoneInfo[ zone ][ZoneOwnerID] = gTeam[killerid]; // Save to file SaveZones(); //kill timer KillTimer( GangWarTimer[zone] ); } } } // The Player who dies on his own turf else if( ZoneInfo[ zone ][ZoneOwnerID] == gTeam[playerid] ) { GangInfo[ gTeam[playerid] ][UnderAttackCount]++; // start the gang war if(GangInfo[ gTeam[playerid] ][UnderAttackCount] == GANGAREA_WARNINGS) { GetPlayerName(killerid, str, sizeof(str)); SendClientMessageToAll(COLOR_RED," "); format(str, sizeof(str), "*** GangZone Message: %s from %s has STARTED a GANG WAR with %s ", str,GangInfo[ gTeam[killerid] ][GangName], GangInfo[ gTeam[playerid] ][GangName] ); SendClientMessageToAll(GetPlayerColor(killerid), str); SendClientMessageToAll(COLOR_RED," "); GangZoneFlashForAll(zone, GetPlayerColor(killerid) ); ZoneInfo[zone][GangWarInProgress] = 1; ZoneInfo[zone][ZoneAttackers] = gTeam[killerid]; // If after x minutes the zone isnt taken then the defending gang keep their turf GangWarTimer[zone] = SetTimerEx("EndGangWar",GANGWAR_LENGTH,false,"iii",zone, gTeam[killerid], gTeam[playerid] ); return 1; } // Gang has taken the other gangs turf if( (GangInfo[ gTeam[playerid] ][UnderAttackCount] == GANGAREA_TAKE) && (ZoneInfo[zone][ZoneAttackers] == gTeam[killerid]) ) { // send the message GetPlayerName(killerid, str, sizeof(str)); SendClientMessageToAll(COLOR_RED," "); format(str, sizeof(str), "*** GangZone Message: %s from %s has TAKEN %s Turf", str,GangInfo[ gTeam[killerid] ][GangName], GangInfo[ gTeam[playerid] ][GangName] ); SendClientMessageToAll(GetPlayerColor(killerid), str); SendClientMessageToAll(COLOR_RED," "); format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~ %s have taken~n~ %s turf",GangInfo[ gTeam[killerid] ][GangName], GangInfo[ gTeam[playerid] ][GangName] ); GameTextForAll(str,3000,3); // kill the end gangwar timer if( GangWarTimer[zone] ) KillTimer( GangWarTimer[zone] ); // change the zone colour GangZoneStopFlashForAll( zone ); GangZoneHideForAll( zone ); GangZoneShowForAll( zone, GetPlayerColor(killerid) ); // reset the counter GangInfo[ gTeam[killerid] ][UnderAttackCount] = 0; GangInfo[ gTeam[playerid] ][UnderAttackCount] = 0; // save the current zone colour for new players to see GangZone_CurrentColour[ zone ] = GetPlayerColor(killerid); // save the new owner of the zone strmid(ZoneInfo[ zone ][ZoneOwner], GangInfo[ gTeam[killerid] ][GangName], 0, strlen(GangInfo[ gTeam[killerid] ][GangName]), MAX_PLAYER_NAME); ZoneInfo[ zone ][ZoneOwnerID] = gTeam[killerid]; //save zones to file SaveZones(); } } } } SetPlayerScore(killerid, GetPlayerScore(killerid)+1); SetPlayerMoney(killerid, GetPlayerMoney(killerid)+3000); GameTextForPlayer(killerid,"~g~OWNED",1500,1); GameTextForPlayer(playerid,"~r~WASTED",4000,1); return 1; } else if(gTeam[killerid] == gTeam[playerid]) { TeamKills[killerid]++; SendClientMessage(killerid, COLOR_RED, "Warning! You have been punished for teamkilling"); GivePlayerMoney(killerid, -1000); SetPlayerScore(killerid, GetPlayerScore(killerid) - 1); GameTextForPlayer(killerid,"~r~TEAM KILLER",5000,3); GetPlayerName(killerid, str, sizeof(str)); if(TeamKills[killerid] >= MAX_TEAMKILLS_FORJAIL && TeamKills[killerid] != MAX_TEAMKILLS) { SetPlayerPos(killerid,264.21, 77.57, 1001.03); SetPlayerInterior(killerid,6); JailTimer[killerid] = SetTimerEx("JailRelease",JAIL_TIME,0,"i",killerid); InJail[killerid] = 1; format(str, sizeof(str), "* JAIL: %s has been jailed, you can release this player by paying the bail fee at the police station", str); SendClientMessageToAll(COLOR_RED, str); } if(TeamKills[killerid] == MAX_TEAMKILLS) { format(str, sizeof(str), "*AutoKick: %s has been kicked for excessive teamkilling", str); SendClientMessageToAll(COLOR_RED, str); Kick(killerid); } return 1; } } return 1; }
Код:
public OnPlayerSpawn(playerid) { HideAllTextDraws(playerid); SetTeamToPlayer(playerid); GivePlayerMoney(playerid, 2500); Spawned[playerid] = 1; if(gTeam[playerid] == TEAM_ADMIN && ( !IsPlayerAdmin(playerid) && !IsPlayerLAdmin(playerid) ) ) { ForceClassSelection(playerid); SetPlayerHealth(playerid, 0.0); } if(InJail[playerid] == 1) { SendClientMessage(playerid,red,"You cannot escape your punishment"); SetPlayerPos(playerid,264.21, 77.57, 1001.03); SetPlayerInterior(playerid,6); SetTimerEx("JailRelease",JAIL_TIME,0,"i",playerid); } GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~n~~r~let the war begin",4000,5); PlayerPlaySound(playerid, 1098, 0.0, 0.0, 0.0); //SetPlayerWorldBounds(playerid,2956.05,74.0432,-899.8585,-2929.94); //WORLD BOUNDARIES Los Santos SetPlayerInterior(playerid,0); if(gTeam[playerid] == TEAM_GROVE) { SetPlayerColor(playerid,COLOR_GREEN); SetPlayerInterior(playerid,0); } else if(gTeam[playerid] == TEAM_BALLAS) SetPlayerColor(playerid,COLOR_PURPLE); else if(gTeam[playerid] == TEAM_AZTEC) SetPlayerColor(playerid,COLOR_LIGHTBLUE); else if(gTeam[playerid] == TEAM_NANG) SetPlayerColor(playerid,COLOR_DARKRED); else if(gTeam[playerid] == TEAM_VAGOS) SetPlayerColor(playerid,COLOR_YELLOW); else if(gTeam[playerid] == TEAM_COPS) SetPlayerColor(playerid,COLOR_BLUE); else if(gTeam[playerid] == TEAM_MAFIA) SetPlayerColor(playerid,COLOR_BLACK); else if(gTeam[playerid] == TEAM_BIKER) SetPlayerColor(playerid,COLOR_ORANGE); else if(gTeam[playerid] == TEAM_TRIAD) SetPlayerColor(playerid,COLOR_WHITE); else if(gTeam[playerid] == TEAM_ADMIN) { SetPlayerColor(playerid,COLOR_GOLD); GivePlayerWeapon(playerid,34,200); GivePlayerWeapon(playerid,16,50); } else if(gTeam[playerid] == TEAM_ARMY) { SetPlayerColor(playerid,COLOR_DARKBROWN); SetPlayerFacingAngle(playerid,90); GivePlayerWeapon(playerid,16,7); } else if(gTeam[playerid] == TEAM_LOWRIDER) SetPlayerColor(playerid,red); else if(gTeam[playerid] == TEAM_SKATER) SetPlayerColor(playerid,Skater_grey); else if(gTeam[playerid] == TEAM_UNDERTAKER) SetPlayerColor(playerid,COLOR_PINK); else if(gTeam[playerid] == TEAM_WORKER) SetPlayerColor(playerid,Worker_green); return 1; }