AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] half_rounds and then only count until 16 Score (https://forums.alliedmods.net/showthread.php?t=172557)

jppmarujo 11-22-2011 13:21

[Help] half_rounds and then only count until 16 Score
 
Hey there guys,

So, i'm really new in scripting, i've been spending the last 5 days reading about pawn, AMX Mod X scripting and the tutorials available in here, and i'm starting to understand source files of some basic plugins.

So, i'm trying to edit this plugin: https://sourcemod.net/showthread.php?t=90898

What happens in that plugin is that it switches teams based on the number of rounds we want to make a half. So, i want the first half of the 'game' to be played within 15 rounds (for example: CT Team score: 9 ; T Team score: 6).

After that, and here it is the problem, i want it to be played until any of the teams reaches, first, the score 16 (which means, in the example above, that the CT team have to score 7 more rounds or the T Team has to score 10 more rounds).

But the plugin is defined for, after team switches, play the same number of rounds that we define has half (being that: if i define it to 15 rounds, it switches the teams, and then they have to play 15 MORE rounds).

The code that i'm editing is here:

PHP Code:

//This is a try of editing a plugin to make
//my first plugin

#include <amxmodx>
#include <cstrike>

new half_roundsrounds_countround_left
new enableMaxplayerslive

new TEAM_T[] = "Terrorist"
new TEAM_CT[] = "Counter-Terrorist"

public plugin_init() 
{
    
register_plugin("PCW on Public Server""1.0""jppmarujo")
    
    
enable register_cvar("pcw_on","1")
    
half_rounds register_cvar("pcw_half_rounds","15")
    
live register_cvar("pcw_live","1")
    
    
    
Maxplayers get_maxplayers();
    
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_event("TextMsg""Event_TextMsg""a""2&#Game_C""2=#Game_will_restart_in")
    
register_event("SendAudio""event_round_end""a""2&%!MRAD_terwin""2&%!MRAD_ctwin""2&%!MRAD_rounddraw"
}

public 
event_round_start()
{
    if(
get_pcvar_num(enable)==1)
    {
    
client_print(0print_chat"rounds"rounds_countget_pcvar_num(half_rounds))

set_cvar_num("mp_maxrounds"get_pcvar_num(half_rounds)*2

I'm sorry for the text being so long and not saying almost anything, but as i stated, i'm only starting. SO, i'm guessing the last line of code is saying to set the mp_maxrounds like half_rounds X 2 , right? But that's not what i want, and i can't find a way to set the finish to when team reaches 16 SCORE and not 15 more rounds.

I'm stuck here. I thank you in advance for your help.

jppmarujo 11-22-2011 18:32

Re: [Help] half_rounds and then only count until 16 Score
 
Do i have to, in the beginning state a function that would finish the match when a team wins 16 rounds? Or should i build this divided in like 2 halfs? The first one when it counts 15 rounds and then switches teams, and the second one counting the rounds not in total but for a singular team (until one of them reaches 16)?

quark 11-22-2011 18:55

Re: [Help] half_rounds and then only count until 16 Score
 
Quote:

Originally Posted by AlliedModders Rules
Do not "bump" your threads. Bumping is posting simply to make the thread higher in the forum sort order.

you have an edit button, that u can use!

jppmarujo 11-22-2011 18:59

Re: [Help] half_rounds and then only count until 16 Score
 
Sorry about that. Not trying to bump, i was posting my doubt as i've been thinking and trying to see the problem and solve it from diferent perspectives.

Anyway, i'm not going to do it again, thanks for the warning.

quark 11-22-2011 19:10

Re: [Help] half_rounds and then only count until 16 Score
 
Quote:

Originally Posted by jppmarujo
The first one when it counts 15
rounds and then switches teams, and the second one counting the rounds
not in total but for a singular team
(until one of them reaches 16)!

I think you should do this :)

quark 11-22-2011 19:13

Re: [Help] half_rounds and then only count until 16 Score
 
You can also see other codes like this!

jppmarujo 11-22-2011 19:58

Re: [Help] half_rounds and then only count until 16 Score
 
I've been looking at that code, but i can't find the way that p1mp finds the winner team..

Xellath 11-23-2011 06:02

Re: [Help] half_rounds and then only count until 16 Score
 
From your post, I assume that you want it to restart after 15 rounds, but not reset the team score. However, if a team reaches 16 rounds - the team wins - and everything is reset.

Below code is just the basic thought behind this to show you how;

Code:
#include < amxmodx > #include < cstrike > // team names // CS_TEAM_UNASSIGNED // CS_TEAM_T // CS_TEAM_CT // CS_TEAM_SPECTATOR new const TeamNames[ CsTeams ][ ] = {     "",     "Terrorist",     "Counter-Terrorist",     "" }; // variable holding the current round new CurrentRound; // bool whether it's the 15th round or not new bool:LastRound; // current team round count new RoundsWon[ CsTeams ]; public plugin_init( ) {     // hook round start     register_logevent( "LogEvent_RoundStart", 2, "1=Round_Start" );         // hook round win     register_event( "SendAudio", "Event_SendAudio_TWin", "a", "2&%!MRAD_terwin" );     register_event( "SendAudio", "Event_SendAudio_CTWin", "a", "2&%!MRAD_ctwin" ); } public LogEvent_RoundStart( ) {     // increment round counter     CurrentRound++;         // check if rounds == 15, if so, set last true (will be handled when round is won by a team)     if( CurrentRound == 15 )     {         LastRound = true;     } } public Event_SendAudio_TWin( ) {     // increment the team round counter for T team     RoundsWon[ CS_TEAM_T ]++;         // check if they have 16 rounds in the bag     CheckWinner( CS_TEAM_T );         // if it's the 15th round, reset the round counter, but not the team round counter     if( LastRound )     {         Reset( );     } } public Event_SendAudio_CTWin() {     // increment the team round counter for CT team     RoundsWon[ CS_TEAM_CT ]++;         // check if they have 16 rounds in the bag     CheckWinner( CS_TEAM_CT );         // if it's the 15th round, reset the round counter, but not the team round counter     if( LastRound )     {         Reset( );     } } CheckWinner( CsTeams:Team ) {     // check if team has won 16 rounds     if( RoundsWon[ Team ] == 16 )     {         client_print( 0, print_chat, "%s team has won 16 rounds now, resetting!", TeamNames[ Team ] );                 // reset         Reset( true );     } } Reset( bool:TeamWon = false ) {     // check if a teamwon is true (false by default), if so (see comment below)     if( TeamWon )     {         // reset rounds for terrorists and cts         for( new CsTeams:Team = CS_TEAM_T; Team <= CS_TEAM_CT; Team++ )         {             RoundsWon[ Team ] = 0;         }     }         // set round counter to 0     CurrentRound = 0;         // restart round     server_cmd( "sv_restartround 1" );         // set last round false     LastRound = false; }

enjoi. 11-23-2011 08:27

Re: [Help] half_rounds and then only count until 16 Score
 
stop posting in bold holy fuck

jppmarujo 11-23-2011 12:55

Re: [Help] half_rounds and then only count until 16 Score
 
Xellath,

Your help is just amazing.

Thank you very much. With the comments, i'm able to understand every step of the code.

It's because of helpful people like you that we, begginers, register and like this forum. I always see people talking about karma+ , but i'm not familiar with that feature. When i have suficient threads or posts, or when i fully understand how that works, be sure that i will be giving you some Karma points.

I will now try to modificate some stuff, add other features, etc, to increase my skills and pratice.


Thanks again.


All times are GMT -4. The time now is 08:30.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.