PDA

View Full Version : help for scripting code


smartsl
05-11-2004, 07:27
Hi, developer. i used the Amx Match Deluxe 1.71 plugin of amxmodx in cs1.6. But i found the command "amx_swapteams" didn't work at all. i have seen the relative source code:

public swap()
{
new playersCT[32]
new playersT[32]
new nbrCT,nbrT
get_players(playersCT,nbrCT,"e","CT")
get_players(playersT,nbrT,"e","TERRORIST")
for(new i = 0; i < nbrCT; i++) {
engclient_cmd(playersCT[i], "chooseteam")
engclient_cmd(playersCT[i], "menuselect", "1")
if (is_user_bot(playersCT[i]))
engclient_cmd(playersCT[i], "menuselect", "2")
else
client_cmd(playersCT[i], "slot2")
}
for(new i = 0; i < nbrT; i++) {
engclient_cmd(playersT[i], "chooseteam")
engclient_cmd(playersT[i], "menuselect", "2")
if (is_user_bot(playersT[i]))
engclient_cmd(playersT[i], "menuselect", "4")
else
client_cmd(playersT[i], "slot4")
}
return PLUGIN_CONTINUE
}


i didn't understand the SMALL Programming Language, it's so different from C/C++. i didn't know what does "engclient_cmd" "is_user_bot" mean exactly, so i read the 'amxmodx.inc'. After that, i thought the code above has no errors.

Is there some one can help me and tell me how to let the swap function work in cs1.6?

PM
05-11-2004, 09:10
at the moment, it is not sure whether engclient_cmd actually works on steam. I heard it doesn't but havent had time to test it yet...

BAILOPAN
05-11-2004, 14:32
It works, but not for everything... use client_cmd

QwertyAccess
05-11-2004, 21:40
whats the diffrence exactly :-|

Ingram
05-11-2004, 22:35
client_cmd makes it so the client types the command in their console, allowing plugins to "intercept" the command

engclient_cmd just runs the command on the client, without sending it to them to run

IceMouse[WrG]
05-11-2004, 22:42
client_cmd makes it so the client types the command in their console, allowing plugins to "intercept" the command

engclient_cmd just runs the command on the client, without sending it to them to run
Basically... But remember that engclient is run by the server, where the client is fully unaware of it
Normal client_cmd is sent to the client to then execute.... So a users settings would never be effected by engclient, but englclient eliminates the server->client->server lag time

Ingram
05-11-2004, 22:58
Also, since engclient_cmd might not work, maybe u should change it to
public swap()
{
new playersCT[32]
new playersT[32]
new nbrCT,nbrT
get_players(playersCT,nbrCT,"ce","CT")
get_players(playersT,nbrT,"ce","TERRORIST")
for(new i = 0; i < nbrCT; i++) {
client_cmd(playersCT[i], "jointeam 1")
client_cmd(playersCT[i], "slot1")
}
for(new i = 0; i < nbrT; i++) {
client_cmd(playersT[i], "jointeam 2")
client_cmd(playersT[i], "slot1")
}
return PLUGIN_CONTINUE
}
but the bots won't change teams...

smartsl
05-12-2004, 04:20
Thx JJkiller, i modified some of ur codes like this:

get_players(playersCT,nbrCT,"e","CT")
get_players(playersT,nbrT,"e","TERRORIST")
...
client_cmd(playersCT[i], "jointeam 1")
client_cmd(playersCT[i], "wait")
client_cmd(playersCT[i], "slot2")
...

i added the 'wait' command, so that the menu in client's screen would be cleared.

Another problem is that when i used the plugin in cs:cz with official_cs_bot_v1.5, the bot wouldn't response.

i have a question yet: where the "jointeam" cmd is? It's neither the cs_console_cmd nor amx_any_function, i couldn't find it out. Of course, it works fine just like "chooseteam & menuselect".

smartsl
05-12-2004, 05:38
For a long-time study, i find the small language is so great. i have solved the official_bots prob. Here's my solution:

//BOT
new nbbCT,nbbT
new botsCT[32][32],botsT[32][32]

public swap()
{
new playersCT[32]
new playersT[32]
new nbrCT,nbrT
new name[32]
get_players(playersCT,nbrCT,"e","CT")
get_players(playersT,nbrT,"e","TERRORIST")

nbbCT=0
for(new i = 0; i < nbrCT; i++) {
if (is_user_bot(playersCT[i]))
{
get_user_name(playersCT[i],name,31)
server_cmd("bot_kick %s",name)
botsCT[nbbCT++]=name
}else
{
client_cmd(playersCT[i], "jointeam 1")
client_cmd(playersCT[i], "wait")
client_cmd(playersCT[i], "slot2")
}
}
nbbT=0
for(new i = 0; i < nbrT; i++) {
if (is_user_bot(playersT[i]))
{
get_user_name(playersT[i],name,31)
server_cmd("bot_kick %s",name)
botsT[nbbT++]=name
}else
{
client_cmd(playersT[i], "jointeam 2")
client_cmd(playersT[i], "wait")
client_cmd(playersT[i], "slot4")
}
}
set_task(0.5,"swap2")
return PLUGIN_CONTINUE
}

public swap2()
{
for(new i = 0; i < nbbCT; i++)
{
server_cmd("bot_add_t %s",botsCT[i])
}
for(new i = 0; i < nbbT; i++)
{
server_cmd("bot_add_ct %s",botsT[i])
}
return PLUGIN_CONTINUE
}