Errors on Invite command
#1

So I made an invite command for my faction system but I don't know how to fix the errors also how do I make so the user has to accept the invite?

/invite command
PHP код:
CMD:invite(playerid,params[])
{
    new 
factionid,rank,pname[MAX_PLAYER_NAME],factionstring[256],inviterid;
    
PlayerInfo[playerid][Rank] = rank;
    
PlayerInfo[playerid][Faction] = factionid;
    if(
sscanf(params,"u",inviterid)) return SendClientMessage(playerid,COLOR_RED"Usage: /invite [PlayerID/Name]");
    if(
PlayerInfo[inviterid][Faction] != 0) return SendClientMessage(playerid,COLOR_RED"That player is already in a faction!");
    if(
PlayerInfo[playerid][Rank] = 10) {
        
GetPlayerName(playerid,pnamesizeof(pname));
        
PlayerInfo[inviterid][Rank] = 1;
        
PlayerInfo[inviterid][Faction] = factionid;
        
format(factionstring,256,"FACTION: %s% %s has invited you to %s%",FactionInfo[factionid][Rank10],pname,FactionInfo[factionid][fname]);
        
SendClientMessage(inviterid,COLOR_RED,factionstring);
    }else {
    
SendClientMessage(playerid,COLOR_RED,"You are not a leader of a faction!");
    return 
1;
    }

Errors:
Quote:

C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2024) : warning 219: local variable "factionid" shadows a variable at a preceding level
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2029) : warning 211: possibly unintended assignment
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2033) : error 032: array index out of bounds (variable "FactionInfo")
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2024) : warning 203: symbol is never used: "factionid"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2024 -- 2039) : warning 209: function "cmd_invite" should return a value
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

Reply
#2

try

pawn Код:
CMD:invite(playerid,params[])
{
    new factionid, pname[MAX_PLAYER_NAME], factionstring[256], inviterid;
    PlayerInfo[playerid][Faction] = factionid;
    if(sscanf(params,"u",inviterid)) return SendClientMessage(playerid,COLOR_RED, "Usage: /invite [PlayerID/Name]");
   
    if(PlayerInfo[inviterid][Faction] != 0) return SendClientMessage(playerid,COLOR_RED, "That player is already in a faction!");
   
    if(PlayerInfo[playerid][Rank] = 10)
    {
        GetPlayerName(playerid,pname, sizeof(pname));
        PlayerInfo[inviterid][Rank] = 1;
        PlayerInfo[inviterid][Faction] = factionid;
        format(factionstring,256,"FACTION: %s% %s has invited you to %s%",FactionInfo[factionid][Rank10],pname,FactionInfo[factionid][fname]);
        SendClientMessage(inviterid,COLOR_RED,factionstring);
    }
    else SendClientMessage(playerid,COLOR_RED,"You are not a leader of a faction!");
    return 1;
}
Reply
#3

pawn Код:
CMD:invite(playerid,params[])
{
    new inviterid;
    if(sscanf(params,"u",inviterid)) return SendClientMessage(playerid,COLOR_RED, "Usage: /invite [PlayerID/Name]");
    if(PlayerInfo[inviterid][Faction] != 0) return SendClientMessage(playerid,COLOR_RED, "That player is already in a faction!");
    if(PlayerInfo[playerid][Rank] == 10)
    {
        new factionid,pname[MAX_PLAYER_NAME],factionstring[64];
        factionid = PlayerInfo[playerid][Faction];
        GetPlayerName(playerid,pname, sizeof(pname));
        PlayerInfo[inviterid][Rank] = 1;
        PlayerInfo[inviterid][Faction] = factionid;
        format(factionstring,256,"FACTION: %s% %s has invited you to %s%",FactionInfo[factionid][Rank10],pname,FactionInfo[factionid][fname]);
        SendClientMessage(inviterid,COLOR_RED,factionstring);
    }
    else SendClientMessage(playerid,COLOR_RED,"You are not a leader of a faction!");
    return 1;
}
Reply
#4

Konsta I get these errors with your code
Quote:

C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2047) : warning 219: local variable "factionid" shadows a variable at a preceding level
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(204 : error 022: must be lvalue (non-constant)
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(204 : warning 215: expression has no effect
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2052) : error 032: array index out of bounds (variable "FactionInfo")
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2047) : warning 203: symbol is never used: "factionid"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

Reply
#5

warning 219: local variable "factionid" shadows a variable at a preceding level, That means you have another global var, Rename the factionid local var to fix that,
Reply
#6

I wanted to change its name and I forgot, sorry.
pawn Код:
CMD:invite(playerid,params[])
{
    new inviterid;
    if(sscanf(params,"u",inviterid)) return SendClientMessage(playerid,COLOR_RED, "Usage: /invite [PlayerID/Name]");
    if(PlayerInfo[inviterid][Faction] != 0) return SendClientMessage(playerid,COLOR_RED, "That player is already in a faction!");
    if(PlayerInfo[playerid][Rank] == 10)
    {
        new _factionid,pname[MAX_PLAYER_NAME],factionstring[64];
        _factionid = PlayerInfo[playerid][Faction];
        GetPlayerName(playerid,pname, sizeof(pname));
        PlayerInfo[inviterid][Rank] = 1;
        PlayerInfo[inviterid][Faction] = _factionid;
        format(factionstring,256,"FACTION: %s% %s has invited you to %s%",FactionInfo[_factionid][Rank10],pname,FactionInfo[_factionid][fname]);
        SendClientMessage(inviterid,COLOR_RED,factionstring);
    }
    else SendClientMessage(playerid,COLOR_RED,"You are not a leader of a faction!");
    return 1;
}
Reply
#7

It still doesn't make you accept the invite it just puts you in the faction
Reply
#8

That's how your command was. I didn't change anything, I only fixed the warnings.
Reply
#9

i know Im wondering how I could make it so the person has to accept
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)