Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************\
- *__________________*
- |*Capture the flag*|
- ____________________
- |*By Ronnie 'Moadi' Pearce*|
- ********************************/
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #define FILTERSCRIPT
- #define CBLUE "{39AACC}"
- #define CDGREEN "{6FA828}"
- #define CWHITE "{FFFFFF}"
- #define CRED "{FF0000}"
- #define COLOR_RED 0xFF0000FF
- #define COLOR_GREEN 0x008000FF
- #define COLOR_LIGHTBLUE 0xADD8E6FF
- #define COLOR_AQUA 0x00FFFFFF
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_BLUE 0x2641FEAA
- #define COLOR_LIGHTRED 0xFF6347AA
- #define COLOR_DARKGREEN 0x006400FF
- new
- ob[4];
- new
- ison,pctp[MAX_PLAYERS],ctpu[2],ctpup,flag[MAX_PLAYERS],skin[MAX_PLAYERS],egun,egun1,ptslimit,
- Float:ctx[MAX_PLAYERS],Float:cty[MAX_PLAYERS],Float:ctz[MAX_PLAYERS],Float:cth[MAX_PLAYERS],Float:ctarm[MAX_PLAYERS],ctint[MAX_PLAYERS],ctvw[MAX_PLAYERS];
- enum cTp
- {
- red,
- blue
- }
- new pts[cTp];
- new
- Float:randomctp[][4] =
- {
- {1340.2469,-1172.0527,369.1609,180.1620},
- {1341.4927,-1362.7784,369.8609,2.6931}
- };
- new
- randomc[] =
- {
- 1,
- 2
- };
- public OnFilterScriptInit()
- {
- ob[0] = CreateObject(13607,1343.09997559,-1364.19995117,371.70001221,0.00000000,0.00000000,0.00000000); //object(ringwalls) (1)
- ob[1] = CreateObject(7445,1340.19995117,-1266.90002441,368.29998779,0.00000000,0.00000000,0.00000000); //object(vegasnroad39) (1)
- ob[2] = CreateObject(13607,1339.50000000,-1167.00000000,371.70001221,0.00000000,0.00000000,0.00000000); //object(ringwalls) (2)
- ob[3] = CreateObject(2914,1340.0812,-1267.0023,372.1815,0.0,0.0,0.0,10);
- return 1;
- }
- public OnFilterScriptExit()
- {
- DestroyObject(ob[0]);
- DestroyObject(ob[1]);
- DestroyObject(ob[2]);
- DestroyObject(ob[3]);
- return 1;
- }
- //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- public OnPlayerDeath(playerid,killerid,reason)
- {
- if(pctp[playerid] == 1)
- {
- new rand = random(sizeof(randomctp));
- new team;
- team = GetPlayerTeam(playerid);
- SetSpawnInfo(playerid,team,0,randomctp[rand][0],randomctp[rand][1],randomctp[rand][2],randomc[rand],egun,500,egun1,500,0,0);
- SetPlayerHealth(playerid,90);
- SpawnPlayer(playerid);
- if(GetPlayerTeam(playerid) == 1)
- {
- SetPlayerSkin(playerid,292);
- }
- if(GetPlayerTeam(playerid) == 2)
- {
- SetPlayerSkin(playerid,0);
- }
- }
- if(flag[playerid] == 1)
- {
- new
- pname[MAX_PLAYER_NAME],
- str[128];
- GetPlayerName(playerid,pname,sizeof(pname));
- format(str,sizeof(str),"Capture the flag: %s has dropped the flag!",pname);
- RemovePlayerAttachedObject(playerid,0);
- flag[playerid] = 0;
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(pctp[i]==1)
- {
- SendClientMessage(i,COLOR_GREEN,str);
- }
- }
- }
- return 1;
- }
- //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- if(pctp[playerid] == 1)
- {
- if(ison == 1)
- {
- if(pickupid == ctpup)
- {
- new
- pname[MAX_PLAYER_NAME];
- GetPlayerName(playerid,pname,sizeof(pname));
- if(GetPlayerTeam(playerid) == 1)
- {
- new str[128];
- format(str,sizeof(str),"Capture the flag:"CBLUE"[Blue team] %s"CDGREEN" has picked up the flag!",pname);
- flag[playerid] = 1;
- SetPlayerCheckpoint(playerid,1340.2469,-1172.0527,369.1609,2);
- SetPlayerAttachedObject( playerid, 0, 2914, 15, 0.014013, 0.077415, -0.424313, 354.422760, 358.421966, 92.942932, 1.000000, 1.000000, 1.000000 );
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(pctp[i] == 1)
- {
- SendClientMessage(playerid,COLOR_GREEN,str);
- }
- }
- }
- if(GetPlayerTeam(playerid) == 2)
- {
- new str[128];
- format(str,sizeof(str),"Capture the flag: "CRED"[Red team] %s"CDGREEN" has picked up the flag!",pname);
- flag[playerid] = 1;
- SetPlayerCheckpoint(playerid,1341.4927,-1362.7784,369.8609,2);
- SetPlayerAttachedObject( playerid, 0, 2914, 15, 0.014013, 0.077415, -0.424313, 354.422760, 358.421966, 92.942932, 1.000000, 1.000000, 1.000000 );
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(pctp[i] == 1)
- {
- SendClientMessage(playerid,COLOR_GREEN,str);
- }
- }
- }
- }
- //------------------------------------------------------------------------------
- if(pickupid == ctpu[0])
- {
- if(GetPlayerTeam(playerid) == 1)
- {
- if(flag[playerid] == 1)
- {
- new
- pname[MAX_PLAYER_NAME],
- str[128];
- GetPlayerName(playerid,pname,sizeof(pname));
- flag[playerid] = 0;
- pts[blue] ++;
- new
- strpt[128];
- RemovePlayerAttachedObject(playerid,0);
- format(strpt,sizeof(strpt),"Capture the flag: "CBLUE"Blue"CDGREEN" team points: %i",pts[blue]);
- format(str,sizeof(str),"Capture the flag: "#CBLUE"%s "CDGREEN"has successfully delivered the flag to his base!",pname);
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(pctp[i] == 1)
- {
- SendClientMessage(playerid,COLOR_GREEN,str);
- SendClientMessage(playerid,COLOR_GREEN,strpt);
- }
- }
- }
- if(pts[blue] == ptslimit)
- {
- DestroyPickup(ctpu[0]);
- DestroyPickup(ctpu[1]);
- DestroyPickup(ctpup);
- new
- wstr[128];
- format(wstr,sizeof(wstr),"Capture the flag: Blue team points: %i - Red team points: %i.",pts[blue],pts[red]);
- SendClientMessageToAll(COLOR_GREEN,wstr);
- if(pts[blue] > pts[red])
- {
- SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Blue team won the match!");
- }
- if(pts[red] > pts[blue])
- {
- SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Red team won the match!");
- }
- pts[red] = 0;
- pts[blue] = 0;
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(pctp[i] == 1)
- {
- SetPlayerPos(i,ctx[i],cty[i],ctz[i]);
- SetPlayerArmour(i,ctarm[i]);
- SetPlayerHealth(i,cth[i]);
- SetPlayerInterior(i,ctint[i]);
- SetPlayerVirtualWorld(i,ctvw[i]);
- SetPlayerColor(i,COLOR_WHITE);
- ResetPlayerWeapons(i);
- SetPlayerTeam(i,0);
- pctp[i] = 0;
- flag[i] = 0;
- ison = 0;
- }
- }
- }
- }
- }
- //------------------------------------------------------------------------------
- if(pickupid == ctpu[1])
- {
- if(GetPlayerTeam(playerid) == 2)
- {
- if(flag[playerid] == 1)
- {
- new
- pname[MAX_PLAYER_NAME],
- str[128];
- GetPlayerName(playerid,pname,sizeof(pname));
- flag[playerid] = 0;
- pts[red] ++;
- RemovePlayerAttachedObject(playerid,0);
- new
- strpt[128];
- format(strpt,sizeof(strpt),"Capture the flag: "CRED"Red "CDGREEN"team points: %i",pts[red]);
- format(str,sizeof(str),"Capture the flag: "#CRED"%s "#CDGREEN"has successfully delivered the flag to his base!",pname);
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(pctp[i] == 1)
- {
- SendClientMessage(playerid,COLOR_GREEN,str);
- SendClientMessage(playerid,COLOR_GREEN,strpt);
- }
- }
- }
- if(pts[red] == ptslimit)
- {
- DestroyPickup(ctpu[0]);
- DestroyPickup(ctpu[1]);
- DestroyPickup(ctpup);
- new
- wstr[128];
- format(wstr,sizeof(wstr),"Capture the flag: Blue team points: %i - Red team points: %i.",pts[blue],pts[red]);
- SendClientMessageToAll(COLOR_GREEN,wstr);
- if(pts[blue] > pts[red])
- {
- SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Blue team won the match!");
- }
- if(pts[red] > pts[blue])
- {
- SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Red team won the match!");
- }
- pts[red] = 0;
- pts[blue] = 0;
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(pctp[i] == 1)
- {
- SetPlayerPos(i,ctx[i],cty[i],ctz[i]);
- SetPlayerArmour(i,ctarm[i]);
- SetPlayerHealth(i,cth[i]);
- SetPlayerInterior(i,ctint[i]);
- SetPlayerVirtualWorld(i,ctvw[i]);
- SetPlayerColor(i,COLOR_WHITE);
- ResetPlayerWeapons(i);
- SetPlayerTeam(i,0);
- pctp[i] = 0;
- flag[i] = 0;
- ison = 0;
- }
- }
- }
- }
- }
- }
- }
- return 1;
- }
- //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- public OnPlayerEnterCheckpoint(playerid)
- {
- DisablePlayerCheckpoint(playerid);
- return 1;
- }
- //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- CMD:ctp(playerid,params[])
- {
- if(isnull(params)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: /ctp [join/quit/start/end]");
- if(ison == 1)
- {
- if(!strcmp(params,"join"))
- {
- if(pctp[playerid] == 1) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are already inside of an event!");
- else
- {
- new rand = random(sizeof(randomctp));
- new randc = random(sizeof(randomc));
- new
- pname[MAX_PLAYER_NAME],
- str[128];
- GetPlayerName(playerid,pname,sizeof(pname));
- GetPlayerPos(playerid,ctx[playerid],cty[playerid],ctz[playerid]);
- GetPlayerHealth(playerid,cth[playerid]);
- GetPlayerArmour(playerid,ctarm[playerid]);
- skin[playerid]=GetPlayerSkin(playerid);
- SetPlayerPos(playerid,randomctp[rand][0],randomctp[rand][1],randomctp[rand][2]);
- SetPlayerTeam(playerid,randomc[randc]);
- if(GetPlayerTeam(playerid) == 1)
- {
- SetPlayerSkin(playerid,292);
- SetPlayerColor(playerid,COLOR_BLUE);
- }
- if(GetPlayerTeam(playerid) == 0)
- {
- SetPlayerSkin(playerid,0);
- SetPlayerColor(playerid,COLOR_RED);
- }
- SetPlayerFacingAngle(playerid,randomctp[rand][3]);
- ctint[playerid] = GetPlayerInterior(playerid);
- ctvw[playerid] = GetPlayerVirtualWorld(playerid);
- ResetPlayerWeapons(playerid);
- SetPlayerInterior(playerid,15);
- SetPlayerVirtualWorld(playerid,15);
- GivePlayerWeapon(playerid,egun,5000);
- GivePlayerWeapon(playerid,egun1,5000);
- SetPlayerArmour(playerid,0);
- SetPlayerHealth(playerid,80);
- format(str,sizeof(str),"%s has joined the event!",pname);
- pctp[playerid] = 1;
- for(new i = 0; i<MAX_PLAYERS; i++)
- {
- if(pctp[i] == 1)
- {
- SendClientMessage(i,COLOR_GREEN,str);
- }
- }
- }
- }
- if(!strcmp(params,"quit"))
- {
- if(pctp[playerid] == 1)
- {
- new
- pname[MAX_PLAYER_NAME],
- str[128];
- GetPlayerName(playerid,pname,sizeof(pname));
- SetPlayerPos(playerid,ctx[playerid],cty[playerid],ctz[playerid]);
- SetPlayerArmour(playerid,ctarm[playerid]);
- SetPlayerHealth(playerid,cth[playerid]);
- SetPlayerInterior(playerid,ctint[playerid]);
- SetPlayerVirtualWorld(playerid,ctvw[playerid]);
- ResetPlayerWeapons(playerid);
- SetPlayerTeam(playerid,0);
- SetPlayerColor(playerid,COLOR_WHITE);
- format(str,sizeof(str),"%s has quitted the event!",pname);
- pctp[playerid] = 0;
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(pctp[i] == 1)
- {
- SendClientMessage(i,COLOR_DARKGREEN,str);
- }
- }
- }
- }
- }
- if(!strcmp(params,"start"))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are not authorized to use this command!");
- else
- {
- if(ison == 1) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You cannot start an event before finishing the current one!");
- else
- {
- new
- pname[MAX_PLAYER_NAME],
- str[128];
- GetPlayerName(playerid,pname,sizeof(pname));
- format(str,sizeof(str),"An event has been started by administrator %s, type (/ctp join)",pname);
- SendClientMessageToAll(COLOR_AQUA,str);
- ison = 1;
- ctpu[0] = CreatePickup(1318,1,1340.2469,-1172.0527,369.1609,15);
- ctpu[1] = CreatePickup(1318,1,1341.4927,-1362.7784,369.8609,15);
- ctpup = CreatePickup(1254,2,1340.0812,-1267.0023,372.1815,15);
- }
- }
- }
- if(!strcmp(params,"end"))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are not authorized to use this command!");
- if(ison == 0) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"There are no events going on at the mean while!");
- else
- {
- new
- pname[MAX_PLAYER_NAME],
- str[128];
- ison = 0;
- GetPlayerName(playerid,pname,sizeof(pname));
- format(str,sizeof(str),"The current event has been finished by administrator %s",pname);
- SendClientMessageToAll(COLOR_LIGHTRED,str);
- DestroyPickup(ctpu[0]);
- DestroyPickup(ctpu[1]);
- DestroyPickup(ctpup);
- new
- wstr[128];
- format(wstr,sizeof(wstr),"Capture the flag: Blue team points: %i - Red team points: %i.",pts[blue],pts[red]);
- SendClientMessageToAll(COLOR_GREEN,wstr);
- if(pts[blue] > pts[red])
- {
- SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Blue team won the match!");
- }
- if(pts[red] > pts[blue])
- {
- SendClientMessageToAll(COLOR_GREEN,"Capture the flag: Red team won the match!");
- }
- pts[red] = 0;
- pts[blue] = 0;
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(pctp[i] == 1)
- {
- SetPlayerPos(i,ctx[i],cty[i],ctz[i]);
- SetPlayerArmour(i,ctarm[i]);
- SetPlayerHealth(i,cth[i]);
- SetPlayerInterior(i,ctint[i]);
- SetPlayerVirtualWorld(i,ctvw[i]);
- SetPlayerColor(i,COLOR_WHITE);
- ResetPlayerWeapons(i);
- SetPlayerTeam(i,0);
- pctp[i] = 0;
- flag[i] = 0;
- }
- }
- }
- }
- if(!strcmp(params,"lock"))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are not authorized to use this command!");
- if(ison == 1)
- {
- new
- pname[MAX_PLAYER_NAME],
- str[128];
- ison = 3;
- GetPlayerName(playerid,pname,sizeof(pname));
- format(str,sizeof(str),"The current event has been locked by administrator %s",pname);
- SendClientMessageToAll(COLOR_GREEN,str);
- }
- }
- if(!strcmp(params,"unlock"))
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are not authorized to use this command!");
- if(ison == 3)
- {
- new
- pname[MAX_PLAYER_NAME],
- str[128];
- ison = 1;
- GetPlayerName(playerid,pname,sizeof(pname));
- format(str,sizeof(str),"The current event has been unlocked by administrator %s",pname);
- SendClientMessageToAll(COLOR_GREEN,str);
- }
- }
- return 1;
- }
- //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- CMD:ctpset(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are not authrozied to use this command!");
- new
- value[10],
- ammount;
- if(sscanf(params,"s[10]i",value,ammount)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE:/ctpset [gun1/gun2/limit] [gunid/ammount]");
- if(!strcmp(value,"gun1"))
- {
- egun = ammount;
- new str[128];
- format(str,sizeof(str),"CTP: You have set the event's gun1 to %i",ammount);
- SendClientMessage(playerid,COLOR_LIGHTRED,str);
- }
- if(!strcmp(value,"gun2"))
- {
- egun1 = ammount;
- new str[128];
- format(str,sizeof(str),"CTP: You have set the event's gun2 to %i",ammount);
- SendClientMessage(playerid,COLOR_LIGHTRED,str);
- }
- if(!strcmp(value,"limit"))
- {
- ptslimit = ammount;
- new str[128];
- format(str,sizeof(str),"CTP: You have set the event's captured flags limit to %i",ammount);
- SendClientMessage(playerid,COLOR_LIGHTRED,str);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement