SA-MP Forums Archive
storing string into varialbe issue, help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: storing string into varialbe issue, help (/showthread.php?tid=181307)



storing string into varialbe issue, help - Hijolion - 04.10.2010

pawn Код:
COMMAND:forcemode(playerid, params[])
{
    if (PlayerInfo[playerid][pAdminLevel] >=3)
    {
    new text[64],string[50];
    if (sscanf(params, "s[64]", text)) SendClientMessage(playerid, COLOR_GOLD, "Usage: /forcemode <modename>");
    storedforcedmode = floatstr(string[50]);
    SetTimer("forcedtochange", 535000,0);
    }
    return 1;
}
forward forcedtochange(playerid);
public forcedtochange(playerid)
{
    SendRconCommand(storedforcedmode);
    return 1;
}
pawn Код:
C:\Users\HIJOL  GOSWAMI\Mini Modes Server 0.3b\filterscripts\ServerR.pwn(863) : error 032: array index out of bounds (variable "string")
C:\Users\HIJOL  GOSWAMI\Mini Modes Server 0.3b\filterscripts\ServerR.pwn(871) : error 035: argument type mismatch (argument 1)
C:\Users\HIJOL  GOSWAMI\Mini Modes Server 0.3b\filterscripts\ServerR.pwn(863) : warning 204: symbol is assigned a value that is never used: "storedforcedmode"
Help?


Re: storing string into varialbe issue, help - LarzI - 04.10.2010

Why do you use floatstr?
And 'string' and 'text' has to be the same size.


Re: storing string into varialbe issue, help - samgreen - 05.10.2010

What the hell is this supposed to do?


Re: storing string into varialbe issue, help - Hijolion - 06.10.2010

According to the suggestions, here are the changes.
pawn Код:
COMMAND:forcemode(playerid, params[])
{
    if (PlayerInfo[playerid][pAdminLevel] >=3)
    {
    new text[64],string[50];
    if (sscanf(params, "s[64]", text)) SendClientMessage(playerid, COLOR_GOLD, "Usage: /forcemode <modename>");
    format(string, sizeof(string), "changemode %s",params);
    storedforcedmode = string[64];
    SetTimer("forcedtochange", 535000,0);
    }
    return 1;
}
forward forcedtochange(playerid);
public forcedtochange(playerid)
{
    SendRconCommand(storedforcedmode);
    return 1;
}
and here's the errors

pawn Код:
C:\Users\HIJOL  GOSWAMI\Mini Modes Server 0.3b\filterscripts\ServerR.pwn(862) : error 032: array index out of bounds (variable "string")
C:\Users\HIJOL  GOSWAMI\Mini Modes Server 0.3b\filterscripts\ServerR.pwn(862) : error 033: array must be indexed (variable "storedforcedmode")



Re: storing string into varialbe issue, help - Voldemort - 06.10.2010

1. error
pawn Код:
new text[64],string[50];
storedforcedmode = string[64];
2. if you are going to use storedforcedmode as text you will need it storedforcedmode[64];

And use
strmid(storedforcedmode,string,0,strlen(string),25 5);
not
storedforcedmode = string[64];
because we not talking about integers

whole edit:
pawn Код:
forward forcedtochange(playerid);
new storedforcedmode[50];

COMMAND:forcemode(playerid, params[])
{
    if (PlayerInfo[playerid][pAdminLevel] >=3)
    {
        new text[40],string[50];
        if (sscanf(params, "s[64]",text))
        {
            SendClientMessage(playerid, COLOR_GOLD, "Usage: /forcemode <modename>"); return 1;
        }
        format(string, sizeof(string), "changemode %s",text);
        strmid(storedforcedmode,string,0,strlen(string),255);
        SetTimer("forcedtochange", 535000,0);
    }
    return 1;
}
public forcedtochange(playerid)
{
    SendRconCommand(storedforcedmode);
    return 1;
}



Re: storing string into varialbe issue, help - LarzI - 06.10.2010

pawn Код:
forward forcedtochange(playerid);
new storedforcedmode[41];

COMMAND:forcemode(playerid, params[])
{
    if (PlayerInfo[playerid][pAdminLevel] >=3)
    {
        new text[40];
        if (sscanf(params, "s[40]",text))
        {
            SendClientMessage(playerid, COLOR_GOLD, "Usage: /forcemode <modename>"); return 1;
        }
        format(storedforcedmode, sizeof(storedforcedmode), "changemode %s",text);
        SetTimer("forcedtochange", 535000,0);
    }
    return 1;
}
public forcedtochange(playerid)
{
    SendRconCommand(storedforcedmode);
    return 1;
}



Re: storing string into varialbe issue, help - Hijolion - 06.10.2010

Quote:
Originally Posted by Voldemort
Посмотреть сообщение
1. error
pawn Код:
new text[64],string[50];
storedforcedmode = string[64];
2. if you are going to use storedforcedmode as text you will need it storedforcedmode[64];

And use
strmid(storedforcedmode,string,0,strlen(string),25 5);
not
storedforcedmode = string[64];
because we not talking about integers

whole edit:
pawn Код:
forward forcedtochange(playerid);
new storedforcedmode[50];

COMMAND:forcemode(playerid, params[])
{
    if (PlayerInfo[playerid][pAdminLevel] >=3)
    {
        new text[40],string[50];
        if (sscanf(params, "s[64]",text))
        {
            SendClientMessage(playerid, COLOR_GOLD, "Usage: /forcemode <modename>"); return 1;
        }
        format(string, sizeof(string), "changemode %s",text);
        strmid(storedforcedmode,string,0,strlen(string),255);
        SetTimer("forcedtochange", 535000,0);
    }
    return 1;
}
public forcedtochange(playerid)
{
    SendRconCommand(storedforcedmode);
    return 1;
}
Thanks buddy! It worked, I never knew that function.