SetLeader CMd
#1

The problem is not saving this on Player DIsconnect Every other THing work fine but OnPlayerDisconnect its not saving Leaders all others things are working Fine

PHP код:
CMD:setleader(playerid,params[])
{
    new 
ID;
    new 
rank;
    new 
NamMAX_PLAYER_NAME ];
    new 
pnameMAX_PLAYER_NAME ];
    new 
str[128];
    if(
IsPlayerAdmin(playerid)|| Player[playerid][pAdmin] >= 5)
    {
    if(
sscanf(params,"ui",ID,rank)) return SendClientMessage(playerid,0xFF9900AA"USAGE: /setLeader [ID] [Level 1-3]");
    if(
rank 3) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-3!");
    if(!
IsPlayerConnected(ID))return SendClientMessage(playerid,0xFF9900AA,"That user is not connected.");
    if(
Player[ID][pLeader] == rank) return SendClientMessage(playerid,0xFF0000FF"ERROR: That person is already Leader!");
    
GetPlayerName(playerid,NamMAX_PLAYER_NAME);
    
GetPlayerName(ID,pname,MAX_PLAYER_NAME);
    
format(strsizeof(str),"%s has set You Leader .",Nam);
    
SendClientMessage(ID,0xFF9900AA,str);
    
format(strsizeof(str),"You had set %s Leader",pname);
    
SendClientMessage(playerid,0xFF9900AA,str);
    
Player[ID][pLeader] = rank;
    if(
Player[ID][pLeader]==1)
    {
    
SetPlayerColor(ID,DARKRED);
    
Player[ID][pcolor]=GetPlayerColor(ID);
    }
    else if(
Player[ID][pLeader]==2)
    {
    
SetPlayerColor(ID,DARKGREEN);
    
Player[ID][pcolor]=GetPlayerColor(ID);
    }
    }
    else
    {
    
SendClientMessage(playeridCOLOR_ORANGE"You Need to Rcon admin Or Higher Admin to use this Cmd");
    }
       return 
1;
}
forward LoadUser_data(playerid,name[],value[]);
public 
LoadUser_data(playerid,name[],value[])
{
    
INI_Int("Leader",Player[playerid][pLeader]);
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
     
INI_WriteInt(File,"Leader",Player[playerid][pLeader]); 
return 
1;

the Problem happen when i setleader 1 it also not save After Relog

then i get this
[11:09:10] [debug] Run time error 6: "Invalid instruction"
[11:09:10] [debug] Unknown opcode 0x202f61d at address 0x00000031
[11:09:10] [debug] AMX backtrace:
[11:09:10] [debug] #0 00000031 in public SSCANF_OnPlayerDisconnect () from New.amx
[11:09:10] [debug] #1 native CallLocalFunction () [00472ad0] from samp-server.exe
[11:09:10] [debug] #2 0001140c in public Streamer_OnPlayerDisconnect (0x00000000, 0x00000001) from New.amx
[11:09:10] [debug] #3 native CallLocalFunction () [00472ad0] from samp-server.exe
[11:09:10] [debug] #4 00010ab0 in ?? (0x00000000, 0x00000001) from New.amx
[11:09:10] [debug] #5 00005454 in public OnPlayerDisconnect (0x00000000, 0x00000001) from New.amx
[11:09:10] [part] Meeee has left the server (0:1)
Reply
#2

You have a missing bracket.
pawn Код:
CMD:setleader(playerid,params[])
{
    new ID;
    new rank;
    new Nam[ MAX_PLAYER_NAME ];
    new pname[ MAX_PLAYER_NAME ];
    new str[128];
    if(IsPlayerAdmin(playerid)|| Player[playerid][pAdmin] >= 5)
    {
    if(sscanf(params,"ui",ID,rank)) return SendClientMessage(playerid,0xFF9900AA, "USAGE: /setLeader [ID] [Level 1-3]");
    if(rank > 3) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-3!");
    if(!IsPlayerConnected(ID))return SendClientMessage(playerid,0xFF9900AA,"That user is not connected.");
    if(Player[ID][pLeader] == rank) return SendClientMessage(playerid,0xFF0000FF, "ERROR: That person is already Leader!");
    GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);
    GetPlayerName(ID,pname,MAX_PLAYER_NAME);
    format(str, sizeof(str),"%s has set You Leader .",Nam);
    SendClientMessage(ID,0xFF9900AA,str);
    format(str, sizeof(str),"You had set %s Leader",pname);
    SendClientMessage(playerid,0xFF9900AA,str);
    Player[ID][pLeader] = rank;
    if(Player[ID][pLeader]==1)
    {
    SetPlayerColor(ID,DARKRED);
    Player[ID][pcolor]=GetPlayerColor(ID);
    }
    else if(Player[ID][pLeader]==2)
    {
    SetPlayerColor(ID,DARKGREEN);
    Player[ID][pcolor]=GetPlayerColor(ID);
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_ORANGE, "You Need to Rcon admin Or Higher Admin to use this Cmd");
    }
}
       return 1;
}
Try this.
Reply
#3

dude no brackets are missings the problem is only on DIsconnct
Reply
#4

Quote:
Originally Posted by MBilal
Посмотреть сообщение
dude no brackets are missings the problem is only on DIsconnct
The error you had, It's because you have a missing bracket
Reply
#5

There is no missing Bracket it Compile i got no bug
Reply
#6

You're not even opening and closing the file on OnPlayerDisconnect.
Reply
#7

dude i didnt post my whole OnPlayerDisconnect here Yet
Reply


Forum Jump:


Users browsing this thread: