21.06.2012, 07:49
ok here we go.
![Picard](images/smilies/picard2.png)
With streamer plugin, you can only show 1 CP at a time, but it will work![Cheesy](images/smilies/biggrin.png)
Download Streamer plugin and place plugin in your plugin folder and inc file in pawn/include.
Add this to your server.cgf
Now here the code.
The defines goes at the top.
Now, we want to create multiple CP and multiple GangZone, so we create an array for it.
We need to define a variable to remember the array index number.So we define
Now, the timer which is needed to check that player must be in CP to capture the zone
Now lets create zones and checkpoints.
To make CP visible to player when he spawns.
To start timer when player enters checkpoint.
And to Kill Timer when player leaves CP
And the rest is same.
FULL CODE :
![Picard](images/smilies/picard2.png)
With streamer plugin, you can only show 1 CP at a time, but it will work
![Cheesy](images/smilies/biggrin.png)
Download Streamer plugin and place plugin in your plugin folder and inc file in pawn/include.
Add this to your server.cgf
Код:
plugins streamer
The defines goes at the top.
pawn Код:
#include <a_samp>
#include <streamer>
#define TEAM_PAKISTAN 0
#define TEAM_GERMANY 1
#define TEAM_USA 2
#define TEAM_RUSSIA 3
#define TEAM_INDIA 4
#define YELLOWA 0xFFFF00AA
#define GREENA 0x008000AA
#define BLUEA 0x0080FFAA
#define REDA 0xFF0000AA
#define ORANGEA 0xFF8000AA
#define RED 0xFF0000FF
#define GREEN 0x008000FF
#pragma tabsize 0
new gTeam[MAX_PLAYERS];
pawn Код:
new Checkpoint[30];
new Zone[30];
pawn Код:
#define GZONE 0 //GangZone5
#define GAS 1//GAS STATION
pawn Код:
new timer[MAX_PLAYERS][30];//30 is max no of Zones, Increase if you want.
pawn Код:
public OnGameModeInit()
{
//See how i used GZONE and GAS to remember which CP is for which
Checkpoint[GZONE] = CreateDynamicCP(-316.7369+10,1594.6285,75.6609,2,-1,-1,-1);
Checkpoint[GAS] = CreateDynamicCP( 611.5208, 1689.866, 15,2,-1,-1,-1);
Zone[GZONE] = GangZoneCreate(-392.1586, 1499.8591, -263.7490, 1630.3291);
Zone[GAS] = GangZoneCreate(521.7093, 1616.373, 677.9031, 1798.172);
return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
TogglePlayerDynamicCP(playerid, Checkpoint[GZONE],1);
TogglePlayerDynamicCP(playerid, Checkpoint[GAS],1);
return 1;
}
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == Checkpoint[GZONE])
{
timer[playerid][GZONE] = SetTimerEx("SetZone",30000,false,"i",playerid);
}
if(checkpointid == Checkpoint[GAS])
{
timer[playerid][GAS] = SetTimerEx("SetZone",30000,false,"i",playerid);
}
return 1;
}
pawn Код:
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
if(checkpointid == Checkpoint[GZONE])
{
KillTimer(timer[playerid][GZONE]);
}
if(checkpointid == Checkpoint[GAS])
{
KillTimer(timer[playerid][GAS]);
}
return 1;
}
pawn Код:
forward SetZone(playerid);
public SetZone(playerid)
{
SetPlayerScore(playerid, GetPlayerScore(playerid) + 3);
GivePlayerMoney(playerid,3000);
SendClientMessage(playerid,GREEN,"Congratulation! You have Gained 3 Scores & 3000$ Money ");
SetGangZone(playerid);
return 1;
}
forward SetGangZone(playerid);
public SetGangZone(playerid)
{
if(gTeam[playerid] == TEAM_PAKISTAN)
{
GangZoneShowForAll(Zone[GAS],GREENA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For Pakistan",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_GERMANY)
{
GangZoneShowForAll(Zone[GAS],ORANGEA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For Pakistan",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_USA)
{
GangZoneShowForAll(Zone[GAS],BLUEA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For USA",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_RUSSIA)
{
GangZoneShowForAll(Zone[GAS],REDA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For RUSSIA",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_INDIA)
{
GangZoneShowForAll(Zone[GAS],YELLOWA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For INDIA",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_PAKISTAN)
{
GangZoneShowForAll(Zone[GZONE],GREENA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For Pakistan",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_GERMANY)
{
GangZoneShowForAll(Zone[GZONE],ORANGEA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For Pakistan",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_USA)
{
GangZoneShowForAll(Zone[GZONE],BLUEA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For USA",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_RUSSIA)
{
GangZoneShowForAll(Zone[GZONE],REDA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For RUSSIA",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_INDIA)
{
GangZoneShowForAll(Zone[GZONE],YELLOWA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For INDIA",pName);
SendClientMessageToAll(0x008000AA,string);
}
return 1;
}
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#include <streamer>
#define TEAM_PAKISTAN 0
#define TEAM_GERMANY 1
#define TEAM_USA 2
#define TEAM_RUSSIA 3
#define TEAM_INDIA 4
#define YELLOWA 0xFFFF00AA
#define GREENA 0x008000AA
#define BLUEA 0x0080FFAA
#define REDA 0xFF0000AA
#define ORANGEA 0xFF8000AA
#define RED 0xFF0000FF
#define GREEN 0x008000FF
#pragma tabsize 0
#define GZONE 0
#define GAS 1
new gTeam[MAX_PLAYERS];
new timer[MAX_PLAYERS][30];
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
new Checkpoint[30];
new Zone[30];
public OnGameModeInit()
{
AddPlayerClass(0, -316.7369-5,1594.6285,75.6609, 269.1425, 0, 0, 0, 0, 0, 0);
Checkpoint[GZONE] = CreateDynamicCP(-316.7369+10,1594.6285,75.6609,2,-1,-1,-1);
Checkpoint[GAS] = CreateDynamicCP( 611.5208, 1689.866, 15,2,-1,-1,-1);
Zone[GZONE] = GangZoneCreate(-392.1586, 1499.8591, -263.7490, 1630.3291);
Zone[GAS] = GangZoneCreate(521.7093, 1616.373, 677.9031, 1798.172);
return 1;
}
public OnPlayerSpawn(playerid)
{
TogglePlayerDynamicCP(playerid, Checkpoint[GZONE],1);
TogglePlayerDynamicCP(playerid, Checkpoint[GAS],1);
return 1;
}
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == Checkpoint[GZONE])
{
timer[playerid][GZONE] = SetTimerEx("SetZone",30000,false,"i",playerid);
SendClientMessage(playerid,0xFFFFFF,"You enter gangZone CP");
}
if(checkpointid == Checkpoint[GAS])
{
timer[playerid][GAS] = SetTimerEx("SetZone",30000,false,"i",playerid);
SendClientMessage(playerid,0xFFFFFF,"You enter GAS CP");
}
return 1;
}
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
if(checkpointid == Checkpoint[GZONE])
{
KillTimer(timer[playerid][GZONE]);
SendClientMessage(playerid,0xFFFFFF,"You left gangZone CP");
}
if(checkpointid == Checkpoint[GAS])
{
KillTimer(timer[playerid][GAS]);
SendClientMessage(playerid,0xFFFFFF,"You left GAS CP");
}
return 1;
}
forward SetZone(playerid);
public SetZone(playerid)
{
SetPlayerScore(playerid, GetPlayerScore(playerid) + 3);
GivePlayerMoney(playerid,3000);
SendClientMessage(playerid,GREEN,"Congratulation! You have Gained 3 Scores & 3000$ Money ");
SetGangZone(playerid);
return 1;
}
forward SetGangZone(playerid);
public SetGangZone(playerid)
{
if(gTeam[playerid] == TEAM_PAKISTAN)
{
GangZoneShowForAll(Zone[GAS],GREENA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For Pakistan",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_GERMANY)
{
GangZoneShowForAll(Zone[GAS],ORANGEA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For Pakistan",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_USA)
{
GangZoneShowForAll(Zone[GAS],BLUEA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For USA",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_RUSSIA)
{
GangZoneShowForAll(Zone[GAS],REDA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For RUSSIA",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_INDIA)
{
GangZoneShowForAll(Zone[GAS],YELLOWA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For INDIA",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_PAKISTAN)
{
GangZoneShowForAll(Zone[GZONE],GREENA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For Pakistan",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_GERMANY)
{
GangZoneShowForAll(Zone[GZONE],ORANGEA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For Pakistan",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_USA)
{
GangZoneShowForAll(Zone[GZONE],BLUEA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For USA",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_RUSSIA)
{
GangZoneShowForAll(Zone[GZONE],REDA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For RUSSIA",pName);
SendClientMessageToAll(0x008000AA,string);
}
if(gTeam[playerid] == TEAM_INDIA)
{
GangZoneShowForAll(Zone[GZONE],YELLOWA);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For INDIA",pName);
SendClientMessageToAll(0x008000AA,string);
}
return 1;
}