AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Confused, extended spawn connect (https://forums.alliedmods.net/showthread.php?t=147376)

Len 01-08-2011 12:35

Confused, extended spawn connect
 
I'm trying to extend the spawn time, IE someone connects joins a team and can spawn if it's less then X% of time into the round.
Also it's meant to block clcmd jointeam whilst already in a team unless the other team has 0 players or wants to join spectator.


Will my vars be permanent in my plugin or only when the plugin is called for example event RoundTime is called so the plugin is executed then handled or will it be working throughout server uptime?
Im going to make a listing of players that have been spawned already so they can't die then jointeam again inside the 40% of round time and spawn again, OR reconnect and do it again so I can't have that^


Also im unsure if I should call sort_players which loops get_players every time a new person connects or if I should set a var to count them as this could mean if the server isn't empty, I won't have a true list?



Also there is some compile errors if you look below:


(P.S there's alot of things I've done that I'm not sure about so if you see anything obvious please could you explain)


Script:
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <cstrike> #include <hamsandwich> /* Not nessecary as script does it by default */ #define mp_limitteams "0" /* vars that will definitely be used */ new time, team_select, Float:spawn_time, no_spawning, new players_ct[32], players_t[32], player[64] /* set the time they can still spawn after round started */ Float:spawn_time = get_cvar_num(mp_roundtime) * 60 Float:spawn_time = Float:spawn_time / 40% public plugin_init() {     register_plugin("Connect waiting", "1.0", "Len")     register_event(RoundTime, round_time(&time), a)     register_event(TeamInfo, select_team(&player), a, 2=TEAM_UNASSIGNED)     register_event(DeathMsg, no_spawn(&no_spawning), a)     register_event(RoundStart,round_start, a)     register_clcmd("jointeam", "block_jointeam") } /* set wether they have already spawned once this round */ public no_spawn() {     no_spawning = get_data(2)     player[no_spawning]_spawned = 1 } /* reset if they have spawned */ public round_start() {     new i     for (i = 1,i <= 32, i++)         players[i]_spawned = 0 } /* set if they already have connected and issue them a team*/ public select_team(&player) {     new id = get_data(1)     sort_players(players_ct, players_t)     player[id]_spawned = 1     if (players_t > players_ct) spawn_player(id, CS_TEAM_CT)         else if (players_t < players_ct) spawn_player(id, CS_TEAM_T)         else cs_set_user_team(id, CS_TEAM_CT)     return PLUGIN_HANDLED } /* block joining team unless, the team they want to join has no players */ public block_jointeam(id) {     new team[2]     read_argv(1, team, 1)         if (team[0] == '3')     {         cs_set_user_team(id, CS_TEAM_SPECTATOR)         return PLUGIN_CONTINUE     }         switch (cs_get_user_team(id)) {         case CS_TEAM_T:         {             if (!players_ct)                 spawn_player(id, CS_TEAM_CT)             else return PLUGIN_HANDLED         }         case CS_TEAM_CT:         {             if (!players_t)                 spawn_player(id, CS_TEAM_T)             else return PLUGIN_HANDLED         }     } } /* Save how many players are on teams CT and T */ public sort_players(&players_ct, &players_t) {     new players[32], num, i     get_players(players[32], num)         for(i = 1,i <= num,i++) {         switch (cs_get_user_team(players[i])         {                 case CS_TEAM_CT:             players_ct++                     case CS_TEAM_T:             players_t++         }     } } /* Save how much time has pasted since round started*/ public round_time(&time)     time = get_data(1) /* Set the players team and spawn if nessecary */ public spawn_player(id, team_select) {     cs_set_user_team(id, team_select)     public spawn_player(id, team_select) {     cs_set_user_team(id, team_select)         if ((time <= Float:spawn_time) && (!player[id]_spawned) &&     (cs_get_user_team(id) == TEAM_UNASSIGNED))     {         ExecuteHamB(Ham_CS_RoundRespawn, id)         return PLUGIN_HANDLED     } }
Compile Errors:
Quote:

/groups/amxmodx/tmp3/textyhDWwp.sma(10) : error 021: symbol already defined: "time"
/groups/amxmodx/tmp3/textyhDWwp.sma(11) : error 020: invalid symbol name ""
/groups/amxmodx/tmp3/textyhDWwp.sma(14) : error 010: invalid function or declaration
/groups/amxmodx/tmp3/textyhDWwp.sma(20) : error 017: undefined symbol "RoundTime"
/groups/amxmodx/tmp3/textyhDWwp.sma(20) : error 029: invalid expression, assumed zero
/groups/amxmodx/tmp3/textyhDWwp.sma(20) : error 029: invalid expression, assumed zero
/groups/amxmodx/tmp3/textyhDWwp.sma(20) : fatal error 107: too many error messages on one line

reinert 01-08-2011 12:55

Re: Confused, extended spawn connect
 
1 error: do not use array names like time, string, new etc... (use something similar such as iTime, g_Time, c_Time...)
2 error: you have left " , " on the end of line (line: 10) replace it with " ; " or delete it...
3 error: Use the floats in plugin init, or after it...
4 error: there is no such thing like RoundTime

sorry I've to go :( read carefully your code, and you will see your mistakes :)

Len 01-08-2011 14:16

Re: Confused, extended spawn connect
 
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <cstrike> #include <hamsandwich> /* Not nessecary as script does it by default */ #define mp_limitteams "0" public plugin_init() {     /* vars that will definitely be used */     new itime, team_select, Float:spawn_time, no_spawning     new players_ct[32], players_t[32], player[64]     /* set the time they can still spawn after round started */     spawn_time = get_cvar_num(mp_roundtime) * 60     spawn_time = spawn_time / 40%     register_plugin("Connect waiting", "1.0", "Len")     register_event(RoundTime, round_time(&itime), a)     register_event(TeamInfo, select_team(&player), a, 2=TEAM_UNASSIGNED)     register_event(DeathMsg, no_spawn(&no_spawning), a)     register_logevent("RoundStart",2,"1=Round_Start")     register_clcmd("jointeam", "block_jointeam") }
Quote:

/groups/amxmodx/tmp3/textpcac0x.sma(15) : error 017: undefined symbol "mp_roundtime"
/groups/amxmodx/tmp3/textpcac0x.sma(16 -- 18) : error 004: function "operator%(Float:,_:)" is not implemented
/groups/amxmodx/tmp3/textpcac0x.sma(18) : error 017: undefined symbol "RoundTime"
/groups/amxmodx/tmp3/textpcac0x.sma(18) : error 029: invalid expression, assumed zero
/groups/amxmodx/tmp3/textpcac0x.sma(18) : fatal error 107: too many error messages on one line

Compilation aborted.
5 Errors.

reinert 01-08-2011 15:49

Re: Confused, extended spawn connect
 
get_cvar_num(mp_roundtime)
->
get_cvar_num("mp_roundtime")

spawn_time = spawn_time / 40%
->
spawn_time = spawn_time / 100 * 40

spawn_time = get_cvar_num(mp_roundtime) * 60
->
round_time = get_cvar_num(mp_roundtime) * 60





Len 01-08-2011 16:01

Re: Confused, extended spawn connect
 
Ah you replied thank you! quoting worked, though the roundtime event still has them compile errors!

http://wiki.alliedmods.net/Half-Life...ents#RoundTime
->
register_event(RoundTime, round_time(&itime))
->
PHP Code:

public round_time(&itime)
{
    
itime get_data(1)


edit: the purpose is to get the current round time, I'm not sure if this is even the right way


All times are GMT -4. The time now is 02:12.

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