11.09.2011, 11:17
Bem, eu nгo pretendo que vocк use isto. Primeiramente porque vocк precisa ter um conhecimento razoбvel para implantar isso no seu gamemode (Nгo й Ctrl+C/V) segundo que eu poderia colocar as cores na DB, mas na йpoca eu nгo sabia que dava pra transformar hex em int e funcionar no samp.
Vou explicar este cуdigo:
Ele cria as gangzones, salva com o owner (org) e domina e pб. Pronto.
Cуdigo:
DB:
Faзa bom proveito.
btw, tem que adicionar na database as gangzones e dar um GMX.
Vou explicar este cуdigo:
Ele cria as gangzones, salva com o owner (org) e domina e pб. Pronto.
Cуdigo:
pawn Код:
#define MAX_GANGZONES 9
//-------------------------------->
#define FACTION_1_COLOR 0x6659FF96
#define FACTION_2_COLOR 0x7BD27D96
#define FACTION_3_COLOR 0xC7ADAD96
#define FACTION_4_COLOR 0x009F0996
#define FACTION_5_COLOR 0xC012C096
#define FACTION_6_COLOR 0xF1E22996
#define FACTION_7_COLOR 0x1FEBFC96
#define FACTION_8_COLOR 0x3100F496
#define FACTION_9_COLOR 0xF4000096
#define FACTION_10_COLOR 0xE9B6B796
#define FACTION_11_COLOR 0xC6000096
#define FACTION_12_COLOR 0x000B8896
#define FACTION_13_COLOR 0xB0B0B096
//-------------------------------->
enum GZ_INFO
{
gzId,
gzName[25],
Float:gzMinX,
Float:gzMinY,
Float:gzMaxX,
Float:gzMaxY,
gzOwner,
gzStats // 0 Normal - 1 Sendo dominada
}
new gangzoneInfo[MAX_GANGZONES][GZ_INFO];
#define GANGZONE_DROP 50
forward GranaTerritorios();
public GranaTerritorios()
{
/*
enum GZ_INFO
{
gzId,
gzName[25],
Float:gzMinX,
Float:gzMinY,
Float:gzMaxX,
Float:gzMaxY,
gzOwner,
gzStats // 0 Normal - 1 Sendo dominada
}*/
new msg[128];
for( new i; i < MAX_GANGZONES; i++ )
{
foreach(Player, a)
{
if( playerInfo[a][pFaction] == gangzoneInfo[i][gzOwner] )
{
format( msg, 128, "Vocк ganhou R$%d por ter em posse o territуrio %s", GANGZONE_DROP, gangzoneInfo[i][gzName] );
SendClientMessage( a, 0xC0C0C0AA, msg );
givePlayerMoney( a, GANGZONE_DROP );
}
}
}
return 1;
}
loadGangZone( gzid )
{
new query[256];
format(query, sizeof(query),"SELECT * FROM `gangzoneinfo` WHERE id=%d",gzid);
mysql_query(query);
mysql_store_result();
if( mysql_num_rows() )
{
if(mysql_fetch_row(query,"|"))
{
printf("[GangZone] A gz [id%d] estб sendo carregada..." , gzid );
new field[7][25];
explode(query, field, "|");
mysql_free_result();
gangzoneInfo[gzid][gzId] = GangZoneCreate( floatstr(field[2]) , floatstr(field[3]) , floatstr(field[4]) , floatstr(field[5]) );
gangzoneInfo[gzid][gzName] = field[1];
gangzoneInfo[gzid][gzMinX] = floatstr( field[2] );
gangzoneInfo[gzid][gzMinY] = floatstr( field[3] );
gangzoneInfo[gzid][gzMaxX] = floatstr( field[4] );
gangzoneInfo[gzid][gzMaxY] = floatstr( field[5] );
gangzoneInfo[gzid][gzOwner] = strval( field[6] );
printf("[GangZone] A gz [id%d] foi carregada com os seguintes dados:" , gzid );
printf("[] ID: %d|Nome: %s|Owner: %d" , gangzoneInfo[gzid][gzId] , gangzoneInfo[gzid][gzName] , gangzoneInfo[gzid][gzOwner] );
printf("[] MinX: %f|MinY: %f|MaxX: %f|MaxY: %f|" , gangzoneInfo[gzid][gzMinX] , gangzoneInfo[gzid][gzMinY] , gangzoneInfo[gzid][gzMaxX] , gangzoneInfo[gzid][gzMaxY] );
printf("[GangZone] A gz [id%d] foi carregada por inteiro." , gzid );
}
}
}
saveGangZone( gzid )
{
new query[50];
format( query , 50 , "UPDATE `gangzoneinfo` SET `owner`=%d WHERE `id`=%d" , gangzoneInfo[gzid][gzOwner] , gzid );
mysql_query(query);
}
IsPlayerInZone(playerid, Float:XMin, Float:YMin, Float:XMax, Float:YMax)
{
new RetValue = 0;
new Float: PosX, Float: PosY, Float: PosZ;
GetPlayerPos( playerid, PosX, PosY, PosZ );
if( PosX >= XMin && PosY >= YMin && PosX < XMax && PosY < YMax )
{
RetValue = 1;
}
return RetValue;
}
forward DominarGz( playerid , g );
public DominarGz( playerid , g )
{
gangzoneInfo[g][gzStats] = 0;
new pF = playerInfo[playerid][pFaction],
gz = gangzoneInfo[g][gzId];
if( IsPlayerInZone(playerid, gangzoneInfo[g][gzMinX] , gangzoneInfo[g][gzMinY] , gangzoneInfo[g][gzMaxX] , gangzoneInfo[g][gzMaxY] ) )
{
gangzoneInfo[g][gzOwner] = pF;
printf( "Gangzone %d atualizada: Owner: %d" , g , gangzoneInfo[g][gzOwner] );
GangZoneStopFlashForAll( gz );
GangZoneHideForAll( gz );
new color;
if( pF == 1 ) color = FACTION_1_COLOR;
if( pF == 2 ) color = FACTION_2_COLOR;
if( pF == 3 ) color = FACTION_3_COLOR;
if( pF == 4 ) color = FACTION_4_COLOR;
if( pF == 5 ) color = FACTION_5_COLOR;
if( pF == 6 ) color = FACTION_6_COLOR;
if( pF == 7 ) color = FACTION_7_COLOR;
if( pF == 8 ) color = FACTION_8_COLOR;
if( pF == 9 ) color = FACTION_9_COLOR;
if( pF == 10 ) color = FACTION_10_COLOR;
if( pF == 11 ) color = FACTION_11_COLOR;
if( pF == 12 ) color = FACTION_12_COLOR;
if( pF == 13 ) color = FACTION_13_COLOR;
GangZoneShowForAll( gz , color );
new str[180];
format( str , 180 , "Atenзгo: %s e %s dominaram o territуrio %s" , getPlayerName( playerid , true ) , factionInfo[pF][fName] , gangzoneInfo[g][gzName] );
SendClientMessageToAll( color , str );
SendClientMessage( playerid , -1 , "Parabйns! Agora este territуrio й seu!" );
}
else
{
GangZoneStopFlashForAll( gz );
SendClientMessage( playerid , -1 , "Como vocк nгo estava na Zona, vocк nгo conquistou o territуrio!" );
}
}
public OnGameModeInit()
{
for( new g; g < MAX_GANGZONES; g++ )
{
loadGangZone( g );
}
SetTimer( "GranaTerritorios", 1000*60*5, true );
}
public OnGameModeExit()
for( new g; g < MAX_GANGZONES; g++ )
saveGangZone(g);
public OnPlayerConnect( playerid )
{
for( new g; g < MAX_GANGZONES; g++ )
{
switch( gangzoneInfo[g][gzOwner] )
{
case 0: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , 0xFFFFFF96 );
case 1: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_1_COLOR );
case 2: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_2_COLOR );
case 3: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_3_COLOR );
case 4: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_4_COLOR );
case 5: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_5_COLOR );
case 6: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_6_COLOR );
case 7: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_7_COLOR );
case 8: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_8_COLOR );
case 9: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_9_COLOR );
case 10: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_10_COLOR );
case 11: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_11_COLOR );
case 12: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_12_COLOR );
case 13: GangZoneShowForPlayer( playerid , gangzoneInfo[g][gzId] , FACTION_13_COLOR );
}
}
}
CMD:dominar( playerid , params[] )
{
#pragma unused params
new pF = playerInfo[playerid][pFaction];
/* Pra checar se ele й da gang */if( pF != 0 && factionInfo[pF][fType] == FACTION_TYPE_MAFIA || factionInfo[pF][fType] == FACTION_TYPE_GANG || factionInfo[pF][fType] == FACTION_TYPE_COP)
{
for( new g; g < MAX_GANGZONES; g++ )
{
if( IsPlayerInZone(playerid, gangzoneInfo[g][gzMinX] , gangzoneInfo[g][gzMinY] , gangzoneInfo[g][gzMaxX] , gangzoneInfo[g][gzMaxY] ) )
{
if( gangzoneInfo[g][gzStats] == 0 )
{
if( pF != gangzoneInfo[g][gzOwner] )
{
new color;
if( pF == 1 ) color = FACTION_1_COLOR;
if( pF == 2 ) color = FACTION_2_COLOR;
if( pF == 3 ) color = FACTION_3_COLOR;
if( pF == 4 ) color = FACTION_4_COLOR;
if( pF == 5 ) color = FACTION_5_COLOR;
if( pF == 6 ) color = FACTION_6_COLOR;
if( pF == 7 ) color = FACTION_7_COLOR;
if( pF == 8 ) color = FACTION_8_COLOR;
if( pF == 9 ) color = FACTION_9_COLOR;
if( pF == 10 ) color = FACTION_10_COLOR;
if( pF == 11 ) color = FACTION_11_COLOR;
if( pF == 12 ) color = FACTION_12_COLOR;
if( pF == 13 ) color = FACTION_13_COLOR;
GangZoneFlashForAll( gangzoneInfo[g][gzId] , color );
SetTimerEx( "DominarGz" , 1000*30 , 0 , "dd" , playerid , g );
new str[128];
format( str , 128 , "Atenзгo: %s e %s estгo dominando o territуrio %s" , getPlayerName( playerid , true ) , factionInfo[pF][fName] , gangzoneInfo[g][gzName] );
SendClientMessageToAll( color , str );
SendClientMessage( playerid , -1 , "Agora que vocк comeзou a dominar, fique na бrea por 30 segundos para conquistar o territуrio!" );
gangzoneInfo[g][gzStats] = 1;
}
else
{
SendClientMessage( playerid , -1 , "Esse territуrio jб pertence ao seu time!" );
}
}
else
{
SendClientMessage( playerid , -1 , "Este territуrio jб estб sendo dominado!" );
}
}
}
return 1;
}
else
return 0;
}
CMD:do( playerid , params[] )
{
return cmd_dominar(playerid, params);
}
Код:
CREATE TABLE IF NOT EXISTS `gangzoneinfo` ( `id` int(11) NOT NULL auto_increment, `name` varchar(25) NOT NULL, `minx` double NOT NULL, `miny` double NOT NULL, `maxx` double NOT NULL, `maxy` double NOT NULL, `owner` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
btw, tem que adicionar na database as gangzones e dar um GMX.