SA-MP Forums Archive
Errors on Invite command - 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: Errors on Invite command (/showthread.php?tid=469258)



Errors on Invite command - lramos15 - 12.10.2013

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.




Re: Errors on Invite command - PT - 12.10.2013

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;
}



Re: Errors on Invite command - Konstantinos - 12.10.2013

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;
}



Re: Errors on Invite command - lramos15 - 12.10.2013

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.




Re: Errors on Invite command - xVIP3Rx - 12.10.2013

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,


Re: Errors on Invite command - Konstantinos - 12.10.2013

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;
}



Re: Errors on Invite command - lramos15 - 12.10.2013

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


Re: Errors on Invite command - Konstantinos - 12.10.2013

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


Re: Errors on Invite command - lramos15 - 12.10.2013

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