AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why the hell won't this work? (https://forums.alliedmods.net/showthread.php?t=152598)

kotinha 03-11-2011 19:37

Why the hell won't this work?
 
Okay, so, I'm getting frustrated with this because the plugin does nothing, but it is active -.-
Call me stupid, retarded, whatever you want but tell me how the hell will this work!
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

new PLUGIN[]="WAR MANAGER"
new AUTHOR[]="THONY"
new VERSION[]="1.00"

new playersready=0

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("TeamScore""team_score""a")
    
register_event("say .startwar""war_start""a")
    
register_event("say .ready""ready""a")
}
public 
war_start()
{
    
client_print(0,print_chat,"[WARMNG] War is starting..."
    if(
get_playersnum(0)!=10) {
        
server_cmd("say [WARMNG] Waiting for all players..."
    }
}

public 
ready() {
    
playersready++;
    if(
playersready==10)
    {
        
set_task(0.1"starting")
    }
}
public 
starting() {
    
server_cmd("say [WARMNG] All players are now ready, game is starting!..."
    
server_cmd("exec warcfg.cfg")
    new 
r
    
for(r=3;r<=1;r--)
    {
        
set_task(1"restart"r)
    }
}
public 
restart(id)
{
    
server_cmd("sv_restart 1")
    
server_cmd("say [WARMNG] Starting in %i"id)



fmfs10 03-11-2011 22:00

Re: Why the hell won't this work?
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

// Use constat because there will be no change
new const PLUGIN[] = "WAR MANAGER"
new const AUTHOR[] = "THONY"
new const VERSION[] = "1.00"

new playersready
new Time

public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("TeamScore""team_score""a")
    
register_event("say .startwar""war_start""a")
    
register_event("say .ready""ready""a")
    
}
public 
war_start()
{
    
client_print(0,print_chat,"[WARMNG] War is starting...")
    
// 0 is unnecessary as it is default value
    
if(get_playersnum() != 10) {
        
server_cmd("say [WARMNG] Waiting for all players...")
    }
}

public 
ready() {
    
playersready++;
    if(
playersready == 10) {
        
// The task is unnecesary...
        
starting()
    }
}
public 
starting() {
    
server_cmd("say [WARMNG] All players are now ready, game is starting!...")
    
server_cmd("exec warcfg.cfg")
    
    
// <= will just make the loop don't work
    
for(new 3;>= 1;r--)
    {
        
// r isn't a id... so removed it :)
        // you don't need a id anyway as it is for all players
        
set_task(1.0"restart")
    }
}
public 
restart()
{
    
// Set Time to the number that you want
    // Time = NUMBER
    
server_cmd("sv_restart 1")
    
server_cmd("say [WARMNG] Starting in %i"Time)


This should work... But there should be a LOT of thinks more for your plugin work correctly, like checking if someone disconnected :)
Oh, and spacing is good you know? :wink:

kotinha 03-11-2011 22:13

Re: Why the hell won't this work?
 
The plugin is not finished yet...
I've tried to say .startwar or .ready and it still does nothing... Shouldn't this say "[WARMNG] War is starting..."? What's wrong with this? :grrr:

And thanks for the tips :wink:

fysiks 03-11-2011 22:50

Re: Why the hell won't this work?
 
Chat commands are not "events". You need to register them as client commands:

PHP Code:

    register_event("say .startwar""war_start""a")
    
register_event("say .ready""ready""a"

:arrow:

PHP Code:

    register_clcmd("say .startwar""war_start")
    
register_clcmd("say .ready""ready"


nikhilgupta345 03-11-2011 22:50

Re: Why the hell won't this work?
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

new const PLUGIN[] = "WAR MANAGER"
new const AUTHOR[] = "THONY"
new const VERSION[] = "1.00"

new playersready
new Time

public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("TeamScore""team_score""a")
    
    
//Register these say commands as clcmds instead of events.
    
register_clcmd("say .startwar""war_start" //Dont need the flags
    
register_clcmd("say .ready""ready" )
    
}
public 
war_start()
{
    
//Check if the players num is 10 before saying that the war is starting.
    
if(get_playersnum() != 10) {
        
server_cmd("say [WARMNG] Waiting for all players...")
    }
    
    else 
client_print(0,print_chat,"[WARMNG] War is starting...")
    
}

public 
ready() {
    
playersready++;
    if(
playersready == 10) {.
        
starting()
    }
}
public 
starting() {
    
server_cmd("say [WARMNG] All players are now ready, game is starting!...")
    
server_cmd("exec warcfg.cfg")
    
    
//Didn'tt need foor loop. Setting the task thrice, when you can do something much simpler.
    
    //Set the time to three here.
    
Time 3;
    
set_task1.0"restart"___"a"); //The second to last parameter signals that it's a repeated command, the last paramater is how many times to repeat
}
public 
restart()
{
    
// Set Time to the number that you want
    
server_cmd("sv_restart 1")
    
server_cmd("say [WARMNG] Starting in %i"Time)
    
    
Time--; //Decrease time for countdown


Try that.


EDIT: Damnit fysiks..

EDIT EDIT: Oops, didn't notice that you registered an even that doesn't have a function. (Teamscore). You coudl take it out if you want.

schmurgel1983 03-12-2011 02:12

Re: Why the hell won't this work?
 
in public starting() why restart? is this not sv_restartround?

infek 03-12-2011 02:44

Re: Why the hell won't this work?
 
Its a task that is set for 3 seconds after those 3 seconds are done it goes to public restart( )

kotinha 03-12-2011 06:26

Re: Why the hell won't this work?
 
Quote:

Originally Posted by nikhilgupta345 (Post 1431760)
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

new const PLUGIN[] = "WAR MANAGER"
new const AUTHOR[] = "THONY"
new const VERSION[] = "1.00"

new playersready
new Time

public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("TeamScore""team_score""a")
    
    
//Register these say commands as clcmds instead of events.
    
register_clcmd("say .startwar""war_start" //Dont need the flags
    
register_clcmd("say .ready""ready" )
    
}
public 
war_start()
{
    
//Check if the players num is 10 before saying that the war is starting.
    
if(get_playersnum() != 10) {
        
server_cmd("say [WARMNG] Waiting for all players...")
    }
    
    else 
client_print(0,print_chat,"[WARMNG] War is starting...")
    
}

public 
ready() {
    
playersready++;
    if(
playersready == 10) {.
        
starting()
    }
}
public 
starting() {
    
server_cmd("say [WARMNG] All players are now ready, game is starting!...")
    
server_cmd("exec warcfg.cfg")
    
    
//Didn'tt need foor loop. Setting the task thrice, when you can do something much simpler.
    
    //Set the time to three here.
    
Time 3;
    
set_task1.0"restart"___"a"); //The second to last parameter signals that it's a repeated command, the last paramater is how many times to repeat
}
public 
restart()
{
    
// Set Time to the number that you want
    
server_cmd("sv_restart 1")
    
server_cmd("say [WARMNG] Starting in %i"Time)
    
    
Time--; //Decrease time for countdown


Try that.


EDIT: Damnit fysiks..

EDIT EDIT: Oops, didn't notice that you registered an even that doesn't have a function. (Teamscore). You coudl take it out if you want.

When compiling this it says:
Code:

/tmp/texttBSbc3.sma(36) : error 029: invalid expression, assumed zero
/tmp/texttBSbc3.sma(37) : warning 217: loose indentation

1 Error.
Could not locate output file /home/groups/amxmodx/public_html/websc3/texttBSbc3.amx (compile failed).

???


EDIT: I tried to change only the client commands part and it didn't work neither :/ It didn't give any errors when compiling but in-game the commands .startwar and .ready don't work (like usually).

tRipLe. 03-12-2011 06:52

Re: Why the hell won't this work?
 
PHP Code:

public ready() {
    
playersready++;
    if(
playersready == 10) {.
        
starting()
    }


Why is that dot after { ?

kotinha 03-12-2011 06:59

Re: Why the hell won't this work?
 
It's there because he wants to mess with me, I think...
It is so small in AMXX Studio that I didn't see it :cry:

Thanks for the reply :wink:

EDIT: F*CKKKKK it still does nothing !! Whyy??!!


All times are GMT -4. The time now is 14:35.

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