SA-MP Forums Archive
array must indexed help me plz - 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)
+--- Thread: array must indexed help me plz (/showthread.php?tid=588990)



array must indexed help me plz - Aagya - 14.09.2015

CoDE:
if(PlayerInfo[playerid][InDM] == 1)
{
new aName[MAX_PLAYER_NAME], string2[128];
GetPlayerName(playerid, aName,sizeof(aName));
format(string2,sizeof(string2),"[DM] %s[%i] : {FFFFFF}%s",aName,playerid,text);
printf(string2);
SendClientMessageToAll(GetPlayerColor(playerid),st ring2);
return 0;
}

Error:
error 033: array must be indexed (variable "InDM")


Re: array must indexed help me plz - PMH - 14.09.2015

Are you declaring that variable anywhere? show us that part or whole enum


Re: array must indexed help me plz - Aagya - 14.09.2015

yea of course, see this
new InDM[MAX_PLAYERS];


Re: array must indexed help me plz - karemmahmed22 - 14.09.2015

PHP код:
if(InDM[playerid] == 1)
{
new 
aName[MAX_PLAYER_NAME], string2[128];
GetPlayerName(playeridaName,sizeof(aName));
format(string2,sizeof(string2),"[DM] %s[%i] : {FFFFFF}%s",aName,playerid,text);
printf(string2);
SendClientMessageToAll(GetPlayerColor(playerid),string2);
return 
0;

This should work.
You simple trying to access the array from enum, which is not in the enum :/
Just use
PHP код:
InDM[playerid] = value 
instead of using PlayerInfo enum :/


Re: array must indexed help me plz - Aagya - 14.09.2015

thx sir!! for help me!!! and sir can u help me for this system

-i want to add this system which will give 25 score and 15000 cash when new players will registered in my server.
My gamemode is COD/TDM


Re: array must indexed help me plz - karemmahmed22 - 14.09.2015

After your register code, just add:
PHP код:
SetPlayerScore(playerid,25);
GivePlayerMoney(playerid,15000); 



Re: array must indexed help me plz - Aagya - 14.09.2015

Quote:
Originally Posted by karemmahmed22
Посмотреть сообщение
After your register code, just add:
PHP код:
SetPlayerScore(playerid,25);
GivePlayerMoney(playerid,15000); 
dude can u make a proper code or add it on ur script or others script and post it here!!!!


Re: array must indexed help me plz - karemmahmed22 - 14.09.2015

Hm, idk what you mean but, you don't need huge code to do it
Just those lines in your register system, if you cannot do it, show me your (OnDialogResponse) i will add it for you


Re: array must indexed help me plz - Aagya - 14.09.2015

PHP код:
case 125:
        {
           if(!
response)
           {
                
Kick(playerid);
           }
           if (
udb_Exists(PlayerName2(playerid))) {
              if (
udb_CheckLogin(PlayerName2(playerid),inputtext))
              {
               new 
file[256], tmp3[100], string[128];
                  
format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(PlayerName2(playerid)) );
                  
GetPlayerIp(playerid,tmp3,100);
                  
dini_Set(file,"ip",tmp3);
               
LoginPlayer(playerid);
               
SetPlayerScore(playerid,25);
               
GivePlayerMoney(playerid,15000);
               
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
               if(
PlayerInfo[playerid][Level] > 0) {
                   
format(string,sizeof(string),"Logged In As An Administrator (Level %d)"PlayerInfo[playerid][Level] );
                   new 
text[128];
               
format(textsizeof(text), "You Are Rank %s."GetRankName(playerid));
                 
SendClientMessage(playeridCOLOR_PINKtext);
                   return 
SendClientMessage(playerid,red,string);
                  } else return 
SendClientMessage(playerid,red,"Logged In As A Registered Player.");
           }
           else {
               
PlayerInfo[playerid][FailLogin]++;
               
printf("LOGIN: %s has failed to login, Wrong password (%s) Attempt (%d)"PlayerName2(playerid),inputtextPlayerInfo[playerid][FailLogin] );
               if(
PlayerInfo[playerid][FailLogin] == MAX_FAIL_LOGINS)
               {
                   new 
string[128]; format(stringsizeof(string), "%s Has Been Kicked From CODWW-2 Server Because He Failed To Login"PlayerName2(playerid) );
                   
SendClientMessageToAll(C_PINKstring);
                   print(string);
                   
Kick(playerid);
                   }
              }
        }
        new 
string[200];
        
format(stringsizeof(string),""cwhite"Welcome "cred"%s "cwhite"you are already registered\nKindly enter password to login to your account\n"cred"Incorrect password!"PlayerName2(playerid));
        
ShowPlayerDialog(playerid125DIALOG_STYLE_INPUT"Login",string,"Login","Kick");
    }
    case 
126:
    {
       if(!
response)
       {
         
Kick(playerid);
       }
      if (
strlen(inputtext) < || strlen(inputtext) > 20) {
          new 
string[200];
          
format(stringsizeof(string),""cwhite"Welcome "cred"%s "cwhite"you are not registered\nKindly enter password to register your account\n"cred"Invalid password length"PlayerName2(playerid));
       
ShowPlayerDialog(playerid126DIALOG_STYLE_INPUT"Register",string,"Register","Kick");
      }
      if (!
udb_Exists(PlayerName2(playerid))) {
      if (
udb_Create(PlayerName2(playerid),inputtext))
      {
        new 
file[256],name[MAX_PLAYER_NAME], tmp3[100];
        new 
strdate[20], year,month,day;    getdate(yearmonthday);
        
GetPlayerName(playerid,name,sizeof(name)); format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(name));
         
GetPlayerIp(playerid,tmp3,100);    dini_Set(file,"ip",tmp3);
//        dini_Set(file,"password",params);
        
dUserSetINT(PlayerName2(playerid)).("registered",1);
           
format(strdatesizeof(strdate), "%d/%d/%d",day,month,year);
        
dini_Set(file,"RegisteredDate",strdate);
        
dini_Set(file,"Nick",name);
        
dUserSetINT(PlayerName2(playerid)).("loggedin",1);
        
dUserSetINT(PlayerName2(playerid)).("banned",0);
        
dUserSetINT(PlayerName2(playerid)).("level",0);
        
dUserSetINT(PlayerName2(playerid)).("LastOn",0);
        
dUserSetINT(PlayerName2(playerid)).("money",15000);
        
dUserSetINT(PlayerName2(playerid)).("Score",15);
        
dUserSetINT(PlayerName2(playerid)).("kills",0);
           
dUserSetINT(PlayerName2(playerid)).("deaths",0);
           
dUserSetINT(PlayerName2(playerid)).("hours",0);
           
dUserSetINT(PlayerName2(playerid)).("minutes",0);
           
dUserSetINT(PlayerName2(playerid)).("seconds",0);
           
dUserSetINT(PlayerName2(playerid)).("dRank",0);
        
PlayerInfo[playerid][LoggedIn] = 1;
        
PlayerInfo[playerid][Registered] = 1;
        
SendClientMessage(playeridgreen"Sucessfully registred, you got $15000 + 15 score as bonus");
        
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
      }
     }
    }
    case 
183:
    {
        if(!
response)
        {
          
ShowPlayerDialog(ID[playerid],183,DIALOG_STYLE_INPUT,"Password After Changing The Name","You Must Added A New Password For Your New Name\n{FF0000}Or Your Account Will Be Lost!","Set","");
        }
        new 
string[128];
        
dUserSetINT(PlayerName2(ID[playerid])).("password_hash",udb_hash(inputtext) );
        
PlayerPlaySound(ID[playerid],1057,0.0,0.0,0.0);
        
format(stringsizeof(string),"You Have Successfully Changed Your Password To \"%s\"",inputtext);
        
SendClientMessage(ID[playerid],yellow,string);
       }
    } 



Re: array must indexed help me plz - X337 - 14.09.2015

Put your code inside tags