array must be indexed (variable "String")
#1

pawn Код:
COMMAND:changename(playerid,params[])
{
    new String[24];if(sscanf(params,"s",String)) return SendClientMessage(playerid,COLOR_RED,""WHITE"Usage:"GREEN"/changename "WHITE"[playerid]");
    if(String > 24 ) return SendClientMessage(playerid,COLOR_RED,"ERROR : the name must be smaller than 24 characters");
    new file[50];format(file,50,"Users/%s.ini",String);//    ==> error line
    if(fexist(file)) return SendClientMessage(playerid,COLOR_RED,"ERROR : the name you have chosen is used by somebody else please choose another one");
    new str[256];
    format(str,256,"%s,%s",pInfo[playerid][Aka],String);
    pInfo[playerid][Aka] = str;
    SetPlayerName(playerid,String);
    return 1;
}
Код:
array must be indexed (variable "String")
Reply
#2

Код:
if(String > 24 )
To
Код:
if(strlen(String) > 24 )
Reply
#3

Use

PHP код:
if(strlen(String) > 24) return SendClientMessage(playerid,COLOR_RED,"ERROR :...."); 
EDIT:
Iggy was faster
Reply
#4

Well iggy his error line is :

pawn Код:
new file[50];format(file,50,"Users/%s.ini",String);//    ==> error line
And also shouldn't it be

pawn Код:
if(strlen(String) > 24)
like this ^?
Reply
#5

worked thanx all
Reply
#6

okay now it prints me this
Код:
[19:28:27] sscanf warning: Strings without a length are deprecated, please add a destination size.
[19:28:27] [nick] [BFV]Opah[COD5] nick changed to name1
[19:28:30] sscanf warning: Strings without a length are deprecated, please add a destination size.
[19:28:30] [nick] name1 nick changed to name2
[19:28:32] [part] name2 has left the server (0:1)
Reply
#7

PHP код:
if(sscanf(params,"s",String)) return SendClientMessage(playerid,COLOR_RED,""WHITE 
Should be:

PHP код:
if(sscanf(params,"s[24]",String)) return SendClientMessage(playerid,COLOR_RED,""WHITE 
Whole command will be:

PHP код:
COMMAND:changename(playerid,params[])
{
    new 
String[24];
    if(
sscanf(params,"s[24]",String)) return SendClientMessage(playerid,COLOR_RED,""WHITE"Usage:"GREEN"/changename "WHITE"[playerid]");
    if(
strlen(String) > 24 ) return SendClientMessage(playerid,COLOR_RED,"ERROR : the name must be smaller than 24 characters");
    new 
file[50];
    
format(file,50,"Users/%s.ini",String);
    if(
fexist(file)) return SendClientMessage(playerid,COLOR_RED,"ERROR : the name you have chosen is used by somebody else please choose another one");
    new 
str[256];
    
format(str,256,"%s,%s",pInfo[playerid][Aka],String);
    
pInfo[playerid][Aka] = str;
    
SetPlayerName(playerid,String);
    return 
1;

Reply
#8

thanx it worked
Reply
#9

Your welcome.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)