forward GangCount(playerid, checkpointid, zonename); public GangCount(playerid, checkpointid, zonename)
public OnPlayerEnterDynamicCP
#include <a_samp> #include <foreach> #include <streamer>
#define LIGHTBLUE 0x33CCFFFF #define RED 0xFF0000FF #define WHITE 0xFFFFFFFF #define LIGHTGREEN 0x33FF33FF #define WHITE_ZONE_COLOR 0xFFFFFF77 #define GREEN_ZONE_COLOR 0x15FF0077 #define GREY 0xAFAFAFFF
#define NoDonorRankHolder 25 //for Regular Players #define Donor1CaptureTime 20 // For Gold VIP(dRank 3) #define Donor2CaptureTime 15 //For Silver VIP(dRank 2) #define Donor3CaptureTime 10 //For Bronze VIP(dRank 1)
#define T_1 100 #define T_2 101
new OnDuty[MAX_PLAYERS];//To BE USed When an admin goes On Duty... new PlayerCount[MAX_PLAYERS]; new PlayerCountTimer[MAX_PLAYERS]; new gTeam[MAX_PLAYERS]; //I Recomemd You To Set This During OnPlayerRequestClass
new AZone; new AArea; new ACP; new AColor;
//Enums enum CaptureInfo { gAttacked = 0, gOwner = 0, } new CaptureZoneInfo[][CaptureInfo]; enum PlayerData { pCaptureZone, drank } new PlayerInfo[MAX_PLAYERS][PlayerData];
{ AZone = GangZoneCreate(-366, 1512, -270, 1578); AArea = CreateDynamicRectangle(-366, 1512, -270, 1578, -1, -1, -1); ACP = CreateDynamicCP(-308.9923,1537.8146,75.5625, 3.0, -1, -1, -1, 100.0); AColor = GREY; return 1; }
{ GangZoneShowForPlayer(playerid, AZone, AColor); return 1; }
stock PlayerArea(playerid) { new pZone; if(IsPlayerInDynamicArea(playerid, AArea)) { GangZoneFlashForAll(AZone, PlayerGangColor(playerid)); pZone = AZone; } return pZone; }
//Which Team Color to FLASH? This Stock Helps stock PlayerGangColor(playerid) { new str; if (gTeam[playerid] == T_1) str =(WHITE_ZONE_COLOR); else if(gTeam[playerid] == T_2) str =(GREEN_ZONE_COLOR); return str; }
//Lets Stock The Names OF The ZONE stock ZoneName(checkpointid) { new str[32]; if (checkpointid == ACP) str = ("A Trial Zone"); return str; }
//The Color To BE Set stock SetZoneColor(zonename, playerid) { if(zonename == AZone) { AColor = PlayerGangColor(playerid); } }
forward OnPlayerEnterDynamicCP(playerid, checkpointid); public OnPlayerEnterDynamicCP(playerid, checkpointid)
forward OnPlayerEnterDynamicCP(playerid, checkpointid); public OnPlayerEnterDynamicCP(playerid, checkpointid) if(checkpointid == ACP) { //Messages InCase The Player Is Not Allowed To Capture new string[128], pZone; [COLOR="rgb(46, 139, 87)"]//If The ZONE is Already Getting Captured[/COLOR] if(CaptureZoneInfo[checkpointid][gAttacked] == 1) return SendClientMessage(playerid, RED, "The zone is being captured!"); //If The Zone Has Been Already Captured By That Team if(CaptureZoneInfo[checkpointid][gOwner] == gTeam[playerid]) return SendClientMessage(playerid, LIGHTBLUE, "Your team owns this zone."); [COLOR="rgb(46, 139, 87)"] //Wether The Player is in a vehicle[/COLOR] if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You cant capture while in a vehicle!"); [COLOR="rgb(46, 139, 87)"] //Wether The Player Is ON Duty(To BE SET)[/COLOR] if(OnDuty[playerid] == 1) return SendClientMessage(playerid, RED, "You cant capture when on duty!"); CaptureZoneInfo[checkpointid][gAttacked] = 1; pZone = PlayerArea(playerid); PlayerInfo[playerid][pCaptureZone] = 1; [COLOR="rgb(46, 139, 87)"] //Checks IF The Player Is a Donor and Correspondingly Sets The TIME For Capture[/COLOR] if(PlayerInfo[playerid][drank] == 1) { PlayerCount[playerid] = Donor1CaptureTime; } else if(PlayerInfo[playerid][drank] == 2) { PlayerCount[playerid] = Donor2CaptureTime; } else if(PlayerInfo[playerid][drank] == 3) { PlayerCount[playerid] = Donor3CaptureTime; } else { PlayerCount[playerid] = NoDonorRankHolder; } [COLOR="rgb(46, 139, 87)"]//Notifying TO The Whole Server That The Zone is Being Taken Over and Prepares The Counting OF [/COLOR]Seconds to Capture PlayerCountTimer[playerid] = SetTimerEx("GangCount", 1000, true, "iii", playerid, checkpointid, pZone); format(string, sizeof(string), "[ZONE] %s is being taken over!", ZoneName(checkpointid)); SendClientMessageToAll(LIGHTGREEN, string); } return 1; }
forward GangCount(playerid, checkpointid, zonename); public GangCount(playerid, checkpointid, zonename) { new time[16]; PlayerCount[playerid] --; format(time, sizeof(time), "~g~%i..", PlayerCount[playerid]); GameTextForPlayer(playerid, time, 1100, 3); if(PlayerCount[playerid] == 0) { CaptureZoneInfo[checkpointid][gAttacked] = 0; GangZoneStopFlashForAll(zonename); GangZoneShowForAll(zonename, PlayerGangColor(playerid)); SetZoneColor(zonename, playerid); //rewards new string[128], Float:armour; format(string, sizeof(string), "You get {FFFF00}+3 score, +20 armor and $2500{FFFFFF} for capturing zone {15FF00}%s!", ZoneName(checkpointid)); SendClientMessage(playerid, WHITE, string); //Cant Give More Than 99 Armour Hence Check IT GetPlayerArmour(playerid, armour); if(armour+20.0 > 99) SetPlayerArmour(playerid, 99); else SetPlayerArmour(playerid, armour+20.0); GivePlayerMoney(playerid, 5000); SetPlayerScore(playerid, GetPlayerScore(playerid)+3); PlayerInfo[playerid][pCaptureZone] = 0; foreach(Player, i) { if(CaptureZoneInfo[checkpointid][gOwner] == gTeam[i]) { format(string, sizeof(string), "Your team has lost the zone {FF0000}%s{FFFFFF}, you lose {FF0000}-1{FFFFFF} score!", ZoneName(checkpointid)); SetPlayerScore(i, GetPlayerScore(i)-1); SendClientMessage(i, WHITE, string); } else if(gTeam[i] == gTeam[playerid]) { if(i != playerid) { format(string, sizeof(string), "Your team has captured the zone {15FF00}%s{FFFFFF}, you get {15FF00}+1{FFFFFF} score!", ZoneName(checkpointid)); SetPlayerScore(i, GetPlayerScore(i)+1); SendClientMessage(i, WHITE, string); } } } KillTimer(PlayerCountTimer[playerid]); CaptureZoneInfo[checkpointid][gOwner] = gTeam[playerid]; } return 1; }
forward OnPlayerLeaveDynamicCP(playerid, checkpointid); public OnPlayerLeaveDynamicCP(playerid, checkpointid) { if(PlayerInfo[playerid][pCaptureZone] == 1) { if(CaptureZoneInfo[checkpointid][gOwner] == gTeam[playerid]) return 0; new pZone; CaptureZoneInfo[checkpointid][gAttacked] = 0; pZone = PlayerArea(playerid); GangZoneStopFlashForAll(pZone); SendClientMessage(playerid, RED, "You stopped capturing the zone!"); KillTimer(PlayerCountTimer[playerid]); PlayerInfo[playerid][pCaptureZone] = 0; } return 1; }
public OnPlayerDeath(playerid, killerid, reason) { { SendClientMessageToAll(playerid, RED, "[Zone] was Not Captured Since The Played Died While Capturing It!"); KillTimer(PlayerCountTimer[playerid]); PlayerInfo[playerid][pCaptureZone] = 0; } return 1; } public OnPlayerDisconnect(playerid, reason) { { SendClientMessageToAll(playerid, RED, "[Zone] Was Not Captured Since The Player Left The Server"); KillTimer(PlayerCountTimer[playerid]); PlayerInfo[playerid][pCaptureZone] = 0; } return 1; }
stock PlayerArea(playerid) { new pZone; if(IsPlayerInDynamicArea(playerid, AArea)) { GangZoneFlashForAll(AZone, PlayerGangColor(playerid)); pZone = AZone; } if(IsPlayerInDynamicArea(playerid, AnotherCaptureArea)) { GangZoneFlashForAll(AnotherCaptureZone, PlayerGangColor(playerid)); pZone = AnotherCaptureZone; } return pZone; }
stock ZoneName(checkpointid) { new str[32]; if (checkpointid == ACP) str = ("A Trial Zone"); if (checkpointid == AnotherCaptureCP) str = ("second Trial Zone"); return str; }
stock SetZoneColor(zonename, playerid) { if(zonename == AZone) { AColor = PlayerGangColor(playerid); } if(zonename == AnotherCaptureZone) { AnotherCaptureColor = PlayerGangColor(playerid); } }
public OnPlayerEnterDynamicCP(playerid, checkpointid) { if(checkpointid == ACP || checkpointid == AnotherCaptureCP )
stock PlayerGangColor(playerid) { new str; if (gTeam[playerid] == T_1) str =(WHITE_ZONE_COLOR); else if(gTeam[playerid] == T_2) str =(GREEN_ZONE_COLOR); else if(gTeam[playerid] == T_3) str =(Orange_ZONE_COLOR); return str; }
Well, I didn't read it all, just saw it at small..
The OnPlayerDeath you didn't even check if player is capturing to make it stop the capture and send the message, that means it will send that message everytime someone dies, same for the OnPlayerDisconnect. The donator rank and admin rank of yours show that this was taken from a gamemode, and not created.. I'd suggest editing it before putting it as a tutorial. For the rest, not bad. {{ PS: SendClientMessageToAll(playerid, etc... ) is wrong. It's SendClientMessageToAll(COLOR, MESSAGE) and not SendClientMessageToAll(playerid, COLOR, MESSAGE).. }} Too busy to find more mistakes. |
enum CaptureInfo
{
gAttacked = 0,
gOwner = 0,
}
#include <a_samp>
enum r_EXAMPLE
{
my_position_is_5 = 5,
my_position_is_10 = 10
}
new rEnum[ 1 ][ r_EXAMPLE ];
main()
{
printf(" %i, %d ", rEnum[ 0 ][ my_position_is_5 ], rEnum[ 0 ][my_position_is_10] );
}
You have a major error in there:
pawn Код:
Read in this (https://sampforum.blast.hk/showthread.php?tid=318307) topic that setting to constants in enums sets their POSITION and not their value. Hence gOwner and gAttacked would be BOTH at the position 0 which is not good. Example - try running this code here. (http://slice-vps.nl:7070/) pawn Код:
|
public OnPlayerDeath(playerid, killerid, reason)
{
{
SendClientMessageToAll(playerid, RED, "[Zone] was Not Captured Since The Played Died While Capturing It!");
KillTimer(PlayerCountTimer[playerid]);
PlayerInfo[playerid][pCaptureZone] = 0;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
{
SendClientMessageToAll(playerid, RED, "[Zone] Was Not Captured Since The Player Left The Server");
KillTimer(PlayerCountTimer[playerid]);
PlayerInfo[playerid][pCaptureZone] = 0;
}
return 1;
}
Could I suggest adding in clearly delineated sections? I use large coloured text to separate them but you are free to use whatever method you like. As it is, this is tricky to follow as everything just runs on.
And Stop Capitalising Every Word, It Is Very Hard To Read. |