From 4ebaf037a002108bf2c66e112a63a397982bce67 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 5 Oct 2018 15:48:24 +0100 Subject: [PATCH 1/5] adds /turfs - showing all the current turfs and the gang who controls it --- gamemodes/sf-cnr.pwn | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index aa00bab..bafbb0d 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -9831,7 +9831,6 @@ thread readclans( playerid ) return 1; } - CMD:gangs( playerid, params[ ] ) { if ( !Iter_Count(gangs) ) @@ -9850,6 +9849,35 @@ CMD:gangs( playerid, params[ ] ) return ShowPlayerDialog( playerid, DIALOG_GANG_LIST, DIALOG_STYLE_TABLIST_HEADERS, "Gangs List", szHugeString, "Select", "Cancel" ); } +CMD:turfs( playerid, params[ ] ) +{ + if ( !Iter_Count( turfs ) ) + return SendError( playerid, "There is currently no trufs on the server." ); + + szHugeString[ 0 ] = '\0'; + + foreach( new turfid : turfs ) + { + new + szLocation[ MAX_ZONE_NAME ], Float: min_x, Float: min_y; + + Streamer_GetFloatData( STREAMER_TYPE_AREA, g_gangTurfData[ turfid ] [ E_AREA ], E_STREAMER_MIN_X, min_x ); + Streamer_GetFloatData( STREAMER_TYPE_AREA, g_gangTurfData[ turfid ] [ E_AREA ], E_STREAMER_MIN_Y, min_y ); + + GetZoneFromCoordinates( szLocation, min_x, min_y ); + + if ( g_gangTurfData[ turfid ][ E_OWNER ] == INVALID_GANG_ID ) { + format( szHugeString, sizeof( szHugeString ), "%s%s\t"COL_GREY"Unoccupied\n", szHugeString, szLocation ); + } + else { + format( szHugeString, sizeof( szHugeString ), "%s%s\t{%06x}%s\n", szHugeString, szLocation, g_gangTurfData[ turfid ][ E_COLOR ] >>> 8 , ReturnGangName( g_gangTurfData[ turfid ][ E_OWNER ] ) ); + } + } + + return ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_TABLIST, ""COL_WHITE"Gang Turfs", szHugeString, "Close", "" ); +} + + CMD:gang( playerid, params[ ] ) { if ( p_Class[ playerid ] != CLASS_CIVILIAN ) return SendError( playerid, "This is restricted to civilians only." ); From 2789c3f234371488b9c4f8fdcad2350291e5cfb6 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 5 Oct 2018 19:14:57 +0100 Subject: [PATCH 2/5] changed /turfs into /gang turfs --- gamemodes/sf-cnr.pwn | 70 ++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index bafbb0d..09e535f 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -9849,40 +9849,38 @@ CMD:gangs( playerid, params[ ] ) return ShowPlayerDialog( playerid, DIALOG_GANG_LIST, DIALOG_STYLE_TABLIST_HEADERS, "Gangs List", szHugeString, "Select", "Cancel" ); } -CMD:turfs( playerid, params[ ] ) -{ - if ( !Iter_Count( turfs ) ) - return SendError( playerid, "There is currently no trufs on the server." ); - - szHugeString[ 0 ] = '\0'; - - foreach( new turfid : turfs ) - { - new - szLocation[ MAX_ZONE_NAME ], Float: min_x, Float: min_y; - - Streamer_GetFloatData( STREAMER_TYPE_AREA, g_gangTurfData[ turfid ] [ E_AREA ], E_STREAMER_MIN_X, min_x ); - Streamer_GetFloatData( STREAMER_TYPE_AREA, g_gangTurfData[ turfid ] [ E_AREA ], E_STREAMER_MIN_Y, min_y ); - - GetZoneFromCoordinates( szLocation, min_x, min_y ); - - if ( g_gangTurfData[ turfid ][ E_OWNER ] == INVALID_GANG_ID ) { - format( szHugeString, sizeof( szHugeString ), "%s%s\t"COL_GREY"Unoccupied\n", szHugeString, szLocation ); - } - else { - format( szHugeString, sizeof( szHugeString ), "%s%s\t{%06x}%s\n", szHugeString, szLocation, g_gangTurfData[ turfid ][ E_COLOR ] >>> 8 , ReturnGangName( g_gangTurfData[ turfid ][ E_OWNER ] ) ); - } - } - - return ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_TABLIST, ""COL_WHITE"Gang Turfs", szHugeString, "Close", "" ); -} - - CMD:gang( playerid, params[ ] ) { if ( p_Class[ playerid ] != CLASS_CIVILIAN ) return SendError( playerid, "This is restricted to civilians only." ); - if ( !strcmp( params, "leader", false, 6 ) ) + if ( !strcmp( params, "turfs", false, 5 ) ) + { + if ( !Iter_Count( turfs ) ) + return SendError( playerid, "There is currently no trufs on the server." ); + + szHugeString[ 0 ] = '\0'; + + foreach( new turfid : turfs ) + { + new + szLocation[ MAX_ZONE_NAME ], Float: min_x, Float: min_y; + + Streamer_GetFloatData( STREAMER_TYPE_AREA, g_gangTurfData[ turfid ] [ E_AREA ], E_STREAMER_MIN_X, min_x ); + Streamer_GetFloatData( STREAMER_TYPE_AREA, g_gangTurfData[ turfid ] [ E_AREA ], E_STREAMER_MIN_Y, min_y ); + + GetZoneFromCoordinates( szLocation, min_x, min_y ); + + if ( g_gangTurfData[ turfid ][ E_OWNER ] == INVALID_GANG_ID ) { + format( szHugeString, sizeof( szHugeString ), "%s%s\t"COL_GREY"Unoccupied\n", szHugeString, szLocation ); + } + else { + format( szHugeString, sizeof( szHugeString ), "%s%s\t{%06x}%s\n", szHugeString, szLocation, g_gangTurfData[ turfid ][ E_COLOR ] >>> 8 , ReturnGangName( g_gangTurfData[ turfid ][ E_OWNER ] ) ); + } + } + + return ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_TABLIST, ""COL_WHITE"Gang Turfs", szHugeString, "Close", "" ); + } + else if ( !strcmp( params, "leader", false, 6 ) ) { new pID @@ -18052,6 +18050,16 @@ stock SaveGangData( gangid ) mysql_single_query( szLargeString ); } +stock IsPlayerGangCoLeader( accountid, gangid ) +{ + for ( new i = 0; i < MAX_COLEADERS; i ++ ) { + if ( g_gangData[ gangid ] [ E_COLEADER ] [ i ] == accountid ) + return true; + } + + return false; +} + stock IsPlayerGangLeader( playerid, gangid, only_leader = 0 ) { if ( g_gangData[ gangid ] [ E_LEADER ] == p_AccountID[ playerid ] ) @@ -21072,7 +21080,7 @@ thread OnListGangMembers( playerid, gangid, page ) for( i = 0, szLargeString[ 0 ] = '\0'; i < rows; i++ ) { cache_get_field_content( i, "NAME", userName ); - format( szLargeString, sizeof( szLargeString ), "%s%s%s\n", szLargeString, cache_get_field_content_int( i, "ONLINE", dbHandle ) ? ( #COL_GREEN ) : ( #COL_WHITE ), userName ); + format( szLargeString, sizeof( szLargeString ), "%s%s%s\t"COL_GREY"%s\n", szLargeString, cache_get_field_content_int( i, "ONLINE", dbHandle ) ? ( #COL_GREEN ) : ( #COL_WHITE ), userName, IsPlayerGangCoLeader( cache_get_field_content_int( i, "USER_ID", dbHandle ), gangid ) ? () : () ); } SetPVarInt( playerid, "gang_members_id", gangid ); From 7e79d90dc027fddc643f3d10abfa8b0cb17c2595 Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 5 Oct 2018 19:23:27 +0100 Subject: [PATCH 3/5] adds /getgang [PLAYER_ID] - returns the gang that the player is in. --- gamemodes/sf-cnr.pwn | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 09e535f..99cdfc0 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -9849,6 +9849,28 @@ CMD:gangs( playerid, params[ ] ) return ShowPlayerDialog( playerid, DIALOG_GANG_LIST, DIALOG_STYLE_TABLIST_HEADERS, "Gangs List", szHugeString, "Select", "Cancel" ); } +CMD:getgang( playerid, params[ ] ) +{ + new + pID + ; + + if ( sscanf( params, "u", pID ) ) return SendUsage( playerid, "/getgang [PLAYER_ID]" ); + else if ( !IsPlayerConnected( pID ) || IsPlayerNPC( pID ) ) return SendError( playerid, "Invalid Player ID." ); + else if ( p_PlayerLogged{ pID } == false ) return SendError( playerid, "This player is not logged in." ); + else + { + if (p_GangID[ pID ] == INVALID_GANG_ID) { + SendServerMessage( playerid, ""COL_GREY"%s(%d) is not in a gang.", ReturnPlayerName( pID ), pID ); + } + else { + SendServerMessage( playerid, ""COL_GREY"%s(%d) is in {%06x}%s", g_gangData[ p_GangID[ pID ] ] [ E_COLOR ] >>> 8, g_gangData[ p_GangID[ pID ] ][ E_NAME ] ); + } + } + + return 1; +} + CMD:gang( playerid, params[ ] ) { if ( p_Class[ playerid ] != CLASS_CIVILIAN ) return SendError( playerid, "This is restricted to civilians only." ); @@ -21080,7 +21102,7 @@ thread OnListGangMembers( playerid, gangid, page ) for( i = 0, szLargeString[ 0 ] = '\0'; i < rows; i++ ) { cache_get_field_content( i, "NAME", userName ); - format( szLargeString, sizeof( szLargeString ), "%s%s%s\t"COL_GREY"%s\n", szLargeString, cache_get_field_content_int( i, "ONLINE", dbHandle ) ? ( #COL_GREEN ) : ( #COL_WHITE ), userName, IsPlayerGangCoLeader( cache_get_field_content_int( i, "USER_ID", dbHandle ), gangid ) ? () : () ); + format( szLargeString, sizeof( szLargeString ), "%s%s%s\n", szLargeString, cache_get_field_content_int( i, "ONLINE", dbHandle ) ? ( #COL_GREEN ) : ( #COL_WHITE ), userName ); } SetPVarInt( playerid, "gang_members_id", gangid ); From be5edf4ddd2bb4107e072573fafdb0e261c1dbce Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 5 Oct 2018 18:38:47 +0000 Subject: [PATCH 4/5] removed test function --- gamemodes/sf-cnr.pwn | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 99cdfc0..d4b5bbc 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -18072,16 +18072,6 @@ stock SaveGangData( gangid ) mysql_single_query( szLargeString ); } -stock IsPlayerGangCoLeader( accountid, gangid ) -{ - for ( new i = 0; i < MAX_COLEADERS; i ++ ) { - if ( g_gangData[ gangid ] [ E_COLEADER ] [ i ] == accountid ) - return true; - } - - return false; -} - stock IsPlayerGangLeader( playerid, gangid, only_leader = 0 ) { if ( g_gangData[ gangid ] [ E_LEADER ] == p_AccountID[ playerid ] ) From b7cb7134bc9847b500129c05a84e6a3d3a5fbd6b Mon Sep 17 00:00:00 2001 From: Steven Howard Date: Fri, 5 Oct 2018 19:39:53 +0100 Subject: [PATCH 5/5] adds turf location when another gang is turfing --- gamemodes/sf-cnr.pwn | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 99cdfc0..4bcb066 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -9778,8 +9778,18 @@ CMD:takeover( playerid, params[ ] ) g_gangzoneAttackCount[ z ] = 0; GangZoneFlashForAll( g_gangTurfData[ z ] [ E_ID ], setAlpha( g_gangData[ gangid ] [ E_COLOR ], 0x80 ) ); SendClientMessage( playerid, g_gangData[ gangid ] [ E_COLOR ], "[TURF]{FFFFFF} You are now beginning to take over the turf. Stay inside the area with your gang for 60 seconds. Don't die." ); - if ( g_gangTurfData[ z ] [ E_OWNER ] != INVALID_GANG_ID ) { - SendClientMessageToGang( g_gangTurfData[ z ] [ E_OWNER ], g_gangData[ g_gangTurfData[ z ] [ E_OWNER ] ] [ E_COLOR ], "[GANG]{FFFFFF} Our territory is being attacked by "COL_GREY"%s"COL_WHITE", defend it!", g_gangData[ g_gangzoneAttacker[ z ] ] [ E_NAME ] ); + + if ( g_gangTurfData[ z ] [ E_OWNER ] != INVALID_GANG_ID ) + { + new + szLocation[ MAX_ZONE_NAME ], Float: min_x, Float: min_y; + + Streamer_GetFloatData( STREAMER_TYPE_AREA, g_gangTurfData[ z ] [ E_AREA ], E_STREAMER_MIN_X, min_x ); + Streamer_GetFloatData( STREAMER_TYPE_AREA, g_gangTurfData[ z ] [ E_AREA ], E_STREAMER_MIN_Y, min_y ); + + GetZoneFromCoordinates( szLocation, min_x, min_y ); + + SendClientMessageToGang( g_gangTurfData[ z ] [ E_OWNER ], g_gangData[ g_gangTurfData[ z ] [ E_OWNER ] ] [ E_COLOR ], "[GANG]{FFFFFF} Our territory at %s is being attacked by "COL_GREY"%s"COL_WHITE", defend it!", g_gangData[ g_gangzoneAttacker[ z ] ] [ E_NAME ] ); } } else