AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   error in my plugin, please help (https://forums.alliedmods.net/showthread.php?t=8854)

skulldiggers 12-29-2004 00:04

error in my plugin, please help
 
Code:

#include <amxmodx>
#include <amxmisc>

new rdys=0, rdy[32], inmatch=0, needed=10,ativo=0

public ready_to_match(id)
{
      new kName[32]
      get_user_name(id,kName,31)

      if(!ativo)
      {
      if(!inmatch)
      {
      if(!rdy[id])
      {
                rdy[id]=1
                rdys++
      }
      else
      {
                client_print(id,print_chat,"** Voce Ja deu ready! **")
                return PLUGIN_CONTINUE
      }

      if(rdys>=needed)
      {
      inmatch=1
      set_task(5.0, "start_the_match")
      }
      }
      }
      else
      {
      client_print(id,print_chat,"** CPL MATCH ESTA DESATIVADA **")
      }
      return PLUGIN_CONTINUE
}

public restart_round(time[])
{
  server_cmd("sv_restartround %s",time)
  return PLUGIN_CONTINUE
}

public restart_msg2()
{
        new host[32]
        get_cvar_string("hostname",host,32)
        client_print(0,print_chat,"%s : [--- LIVE ON NEXT RESTART ---]", host)
        return PLUGIN_CONTINUE
}

public restart_msg3()
{
        new host[32]
        get_cvar_string("hostname",host,32)
        client_print(0,print_chat,"%s : [--- LIVE! LIVE! LIVE! ---]", host)
        return PLUGIN_CONTINUE
}

public say_algo(msg[])
{
        new host[32]
        get_cvar_string("hostname",host,32)
        client_print(0,print_chat,"%s : %s", host, msg)
        return PLUGIN_CONTINUE
}

public start_the_match()
{
        new cfgfile[64]
        new host[32]
        get_cvar_string("hostname",host,32)
        server_cmd("exec %s", cfgfile)
        client_print(0,print_chat,"%s : [--- LIVE IN 3 RESTARTS ---]", host)
        restart_round("1")
        set_task(1.0, "restart_round",0,"1",2)
        set_task(1.1, "restart_msg2")
        set_task(2.0, "restart_round",0,"10",2)
        set_task(2.1, "restart_msg3")
}

public match_info(id)
{
        client_print(id,print_chat,"** Faltam %s dizer !rdy para comecar a partida **", needed-rdys)
        return PLUGIN_CONTINUE
}

public amx_startmatch(id,level,cid)
{
    restart_round("1")
    set_task(1.5, "restart_round",0,"1",2)
    set_task(3.0, "restart_round",0,"5",2)
    set_task(3.0, "last_rr")
    set_task(9.0, "lmessage")
    return PLUGIN_HANDLED
}

public amx_match(id,level,cid)
{
        if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED

        new type[32]
        new need[64]
        read_argv(1, type, 32)
        read_args(need, 64)
        if (equal(type,"0")) {
        ativo=0
        server_cmd("exec 4fun.cfg")
        return PLUGIN_HANDLED
        }
        if (equal(type,"1")) {
        ativo=1
        needed=need
        server_cmd("exec cpl.cfg")
        return PLUGIN_HANDLED
        }
        if (equal(type,"2")) {
        ativo=1
        needed=need
        server_cmd("exec cplot.cfg")
        return PLUGIN_HANDLED
        }
    return PLUGIN_HANDLED
}


public plugin_init()
{
        register_plugin("Cpl Match auto prepare","1.0a","Tr4NInG")
        register_clcmd( "say !rdy", "ready_to_match", 0, "Ready to match" )
        register_clcmd( "say !info", "match_info", 0, "Info of number of readys" )
        register_concmd("amx_match", "amx_match",ADMIN_MAP,"Start or stop a match in server")
}

error:

must be assigned an array

lines: 115.116,121,122



HELP

XxAvalanchexX 12-29-2004 02:25

Code:
needed=need

This is the troublesome code in both cases. The variable "needed" is a single integer, while the variable "need" is an array (rather, a string). Change the code to this:

Code:
needed=str_to_num(need)

skulldiggers 12-29-2004 02:41

ok, i changed the code to

Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

new rdys=0, rdy[32], inmatch=0, ativo=0
new g_teamScore[2]

public ready_to_match(id)
{
      new kName[32]
      get_user_name(id,kName,31)
      new Float:minrdys= get_cvar_float("amx_rdys")

      if(ativo)
      {
      if(!inmatch)
      {
      if(!rdy[id])
      {
                client_print(0,print_chat,"** %s esta Pronto para a partida **", kName)
                rdy[id]=1
                rdys++
      }
      else
      {
                client_print(id,print_chat,"** Voce Ja deu ready! **")
                return PLUGIN_CONTINUE
      }

      if(rdys>=minrdys)
      {
      inmatch=1
      set_task(2.0, "start_the_match")
      }
      }
      }
      else
      {
      client_print(id,print_chat,"** CPL MATCH ESTA DESATIVADA **")
      }
      return PLUGIN_CONTINUE
}

public restart_round(time[])
{
  server_cmd("sv_restartround %s",time)
  return PLUGIN_CONTINUE
}

public restart_msg2()
{
        new host[32]
        get_cvar_string("hostname",host,32)
        client_print(0,print_chat,"%s : [--- LIVE ON NEXT RESTART ---]", host)
        return PLUGIN_CONTINUE
}

public restart_msg3()
{
        new host[32]
        get_cvar_string("hostname",host,32)
        client_print(0,print_chat,"%s : [--- LIVE! LIVE! LIVE! ---]", host)
        return PLUGIN_CONTINUE
}

public say_algo(msg[])
{
        new host[32]
        get_cvar_string("hostname",host,32)
        client_print(0,print_chat,"%s : %s", host, msg)
        return PLUGIN_CONTINUE
}

public start_the_match()
{
        new cfgfile[64]
        new host[32]
        get_cvar_string("hostname",host,32)
        server_cmd("exec %s", cfgfile)
        client_print(0,print_chat,"%s : [--- LIVE IN 3 RESTARTS ---]", host)
        restart_round("1")
        set_task(1.0, "restart_round",0,"1",2)
        set_task(3.0, "restart_msg2")
        set_task(2.0, "restart_round",0,"10",2)
        set_task(13.0, "restart_msg3")
}

public match_info(id)
{
        new Float:minrdys= get_cvar_float("amx_rdys")
        client_print(id,print_chat,"** Faltam %s dizer !rdy para comecar a partida **", minrdys - rdys)
        log_amx("%s Rdys",rdys)
        return PLUGIN_CONTINUE
}

public amx_startmatch(id,level,cid)
{
    restart_round("1")
    set_task(1.5, "restart_round",0,"1",2)
    set_task(3.0, "restart_round",0,"5",2)
    set_task(3.0, "last_rr")
    set_task(9.0, "lmessage")
    return PLUGIN_HANDLED
}

public amx_match(id,level,cid)
{
        if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED

        new type[32]
        read_argv(1, type, 32)
        if (equal(type,"0")) {
        ativo=0
        server_cmd("exec 4fun.cfg")
        }
        if (equal(type,"1")) {
        ativo=1
        server_cmd("exec cpl.cfg")
        }
        if (equal(type,"2")) {
        ativo=1
        server_cmd("exec cplot.cfg")
        }
    return PLUGIN_HANDLED
}

public teamScore(id) {
    new team[2]
    read_data(1,team,1)
    g_teamScore[(team[0]=='C')? 0 : 1] = read_data(2)

    return PLUGIN_CONTINUE
}

public showthescore()
{
if (ativo)
{
new the_score[64]
format(the_score,1023,"CT %s x %s TR",g_teamScore[0], g_teamScore[1])
set_hudmessage(255, 0, 0, -1.0, 0.32, 0, 2.0, 6.0, 0.8, 0.8, 2)
show_hudmessage(0,the_score)
}
}


public plugin_init()
{
        register_plugin("Cpl Match auto prepare","1.0a","Tr4NInG")
        register_clcmd( "say !rdy", "ready_to_match", 0, "Ready to match" )
        register_clcmd( "say !info", "match_info", 0, "Info of number of readys" )
        register_concmd("amx_match", "amx_match",ADMIN_MAP,"Start or stop a match in server")
        register_cvar("amx_rdys","10")
        register_event("TeamScore", "teamScore", "ab")
        register_event("ResetHUD", "showthescore", "b")
}

but in
Code:

public match_info(id)
{
        new Float:minrdys= get_cvar_float("amx_rdys")
        client_print(id,print_chat,"** Faltam %s dizer !rdy para comecar a partida **", minrdys - rdys)
        log_amx("%s Rdys",rdys)
        return PLUGIN_CONTINUE
}

and

Code:

public showthescore()
{
if (ativo)
{
new the_score[64]
format(the_score,1023,"CT %s x %s TR",g_teamScore[0], g_teamScore[1])
set_hudmessage(255, 0, 0, -1.0, 0.32, 0, 2.0, 6.0, 0.8, 0.8, 2)
show_hudmessage(0,the_score)
}
}

have any error because dont show the numbers

only CT x TR or

** Faltam dizer !rdy para comecar a partida **

dont show the numbers..

help me because is my first plugin

XxAvalanchexX 12-29-2004 14:42

%s is for strings, %d is for integers, and %f is for floats.

skulldiggers 12-29-2004 14:53

thx man


All times are GMT -4. The time now is 19:28.

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