Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: sseebbyy on June 10, 2011, 02:22:14 pm

Title: What is wrong ? VIP System
Post by: sseebbyy on June 10, 2011, 02:22:14 pm
 I compiled and everything is good, but when I enter the game and write "/ c makevip 3" for example, nothing happens, and even in folder finding nothing, knows no order.

What should I do?


[pawn]if(strcmp(cmdtext,"makevip",true) == 0)
   {
      if(IsPlayerAdmin(playerid))
      {
      tmp = strtok(cmdtext, idx);
      new plr = FindPlayerIDFromString(tmp);
          if(!strlen(team)) SendClientMessage(playerid,COLOR_LIGHT_RED,"USAGE: /c makevip [Nick/ID]");
         else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_LIGHT_RED,"Error: Unknown player");
         else {
             if(IsVIP[plr] == 0)
             {
            format(szMsg,256,"[VIP SYSTEM]: Admin %s made %s a V.I.P",gPlayers[playerid],gPlayers[plr]);
            SendClientMessageToAll(COLOR_YELLOW,szMsg);
            IsVIP[plr] = 1;
            }
            }
      }
      else
      {
         SendClientMessage(playerid,COLOR_RED,"[VIP SYSTEM]: You are not authorized to use this command");
         }
      return 1;
      }
   else if(strcmp(cmdtext,"takevip",true) == 0)
   {
     if(IsPlayerAdmin(playerid))
      {
      tmp = strtok(cmdtext, idx);
      new plr;
       plr = FindPlayerIDFromString(tmp);
          if(!strlen(tmp)) SendClientMessage(playerid,COLOR_LIGHT_RED,"USAGE: /c takevip [Nick/ID]");
         else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_LIGHT_RED,"Error: Unknown player");
         else {
             if(IsVIP[plr] == 1)
              {
         format(szMsg,256,"[VIP SYSTEM]: Admin %s took %s V.I.P privilegies",gPlayers[playerid],gPlayers[plr]);
         SendClientMessageToAll(COLOR_YELLOW,szMsg);
         IsVIP[plr] = 0;
             }
         else
         {
         SendClientMessage(playerid,COLOR_RED,"[VIP SYSTEM]: That player is not in V.I.P Database");
            }
         }
      }
   return 1;
   }[/pawn]
Title: Re: What is wrong ? VIP System
Post by: yazeen on June 10, 2011, 06:00:39 pm
how is it going to create a dini in a folder without create a function of dini lolz :P
Title: Re: What is wrong ? VIP System
Post by: sseebbyy on June 10, 2011, 07:15:19 pm
[pawn]OnPlayerConnect:

SendClientMessageToAll(COLOR_YELLOW,"[VIP SYSTEM]: Thanks goes out to [RAF]Shadow for his database sistem");
    GetPlayerName(playerid,gPlayers[playerid],MAX_PLAYER_NAME);
      new str[256];
      new file[256];
     format(file,sizeof(file),"Users/Vips/%s.ini",gPlayers[playerid]);
     if(!fexist(file))
         {
           dini_Create(file);
           dini_IntSet(file, "Vip", 0);
           }
         IsVIP[playerid] = dini_Int(file, "Vip");
         if(IsVIP[playerid] == 1)
         {
         format(str,sizeof(str),"[VIP SYSTEM]: V.I.P %s joined the server.",gPlayers[playerid]);
         SendClientMessageToAll(BLUE,str);
         }

OnPlayerDisconnect:

new file[256];
     format(file,sizeof(file),"Users/Vips/%s.ini",gPlayers[playerid]);
     if(!fexist(file))
         {
           dini_Create(file);
           dini_IntSet(file, "Vip", 0);
           }
         dini_IntSet(file, "Vip", IsVIP[playerid]);[/pawn]

i have function !

but the command is the problem...
Title: Re: What is wrong ? VIP System
Post by: sseebbyy on June 10, 2011, 10:42:06 pm
please... enybody
Title: Re: What is wrong ? VIP System
Post by: yazeen on June 11, 2011, 06:29:41 am
please... enybody
Try this not tested caz im using other computer

[pawn]if(strcmp(cmdtext,"makevip",true) == 0)
{
if(IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
new plr = FindPlayerIDFromString(tmp);
if(!strlen(team)) SendClientMessage(playerid,COLOR_LIGHT_RED,"USAGE: /c makevip [Nick/ID]");
else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_LIGHT_RED,"Error: Unknown player");
else {
if(IsVIP[plr] == 0)
{
format(szMsg,256,"[VIP SYSTEM]: Admin %s made %s a V.I.P",gPlayers[playerid],gPlayers[plr]);
format(file,sizeof(file),"Users/Vips/%s.ini",gPlayers[playerid]);
dini_IntSet(file, "Vip", 1);
SendClientMessageToAll(COLOR_YELLOW,szMsg);
IsVIP[plr] = 1;
}
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"[VIP SYSTEM]: You are not authorized to use this command");
}
return 1;
}[/pawn]

Do the same thing to takevip
Title: Re: What is wrong ? VIP System
Post by: stormeus on June 11, 2011, 07:17:11 am
[pawn]
format(file,sizeof(file),"Users/Vips/%s.ini",gPlayers[playerid]);
[/pawn]

Needs to be
[pawn]
format(file,sizeof(file),"Users/Vips/%s.ini",gPlayers[plr]);
[/pawn]
Title: Re: What is wrong ? VIP System
Post by: sseebbyy on June 11, 2011, 10:04:11 am
not work...
Title: Re: What is wrong ? VIP System
Post by: Madara on June 11, 2011, 12:38:07 pm
Line 1 of this code: "cmdtext", depends where you put it in the beginning, definistes, your define (maybe) "cmd = strtok(cmdtext, idx);", therefore, when he writes something, identifies the first parameter and checks to see if it matches one of the command posts, if you put "cmdtext" this does not effect the command, as "cmdtext" sige sequence without waiting for the next token.

Line 4 of this code: "team" not defined, there should have been "tmp"

Code: [Select]
    if(strcmp(cmdtext,"makevip",true) == 0)
{
if(IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
new plr = FindPlayerIDFromString(tmp);
if(!strlen(team)) SendClientMessage(playerid,COLOR_LIGHT_RED,"USAGE: /c makevip [Nick/ID]");
else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_LIGHT_RED,"Error: Unknown player");
else {
    if(IsVIP[plr] == 0)
    {
format(szMsg,256,"[VIP SYSTEM]: Admin %s made %s a V.I.P",gPlayers[playerid],gPlayers[plr]);
SendClientMessageToAll(COLOR_YELLOW,szMsg);
IsVIP[plr] = 1;
}
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"[VIP SYSTEM]: You are not authorized to use this command");
}
return 1;
}

Line 1 of this code: Like the above, there must be "cmd" and not "cmdtext"
Code: [Select]
else if(strcmp(cmdtext,"takevip",true) == 0)
{
  if(IsPlayerAdmin(playerid))
   {
tmp = strtok(cmdtext, idx);
new plr;
plr = FindPlayerIDFromString(tmp);
if(!strlen(tmp)) SendClientMessage(playerid,COLOR_LIGHT_RED,"USAGE: /c takevip [Nick/ID]");
else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_LIGHT_RED,"Error: Unknown player");
else {
if(IsVIP[plr] == 1)
  {
format(szMsg,256,"[VIP SYSTEM]: Admin %s took %s V.I.P privilegies",gPlayers[playerid],gPlayers[plr]);
SendClientMessageToAll(COLOR_YELLOW,szMsg);
IsVIP[plr] = 0;
}
else
{
SendClientMessage(playerid,COLOR_RED,"[VIP SYSTEM]: That player is not in V.I.P Database");
}
}
}
return 1;
}




I took the time to fix and add some things more:
Code: [Select]
    else if(strcmp(cmd,"makevip",true) == 0)
    {
if(IsPlayerAdmin(playerid))
{
        tmp = strtok(cmdtext, idx);
        new plr = FindPlayerIDFromString(tmp);
if(!strlen(tmp)) SendClientMessage(playerid,COLOR_LIGHT_RED,"USAGE: /c makevip [Nick/ID]");
else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_LIGHT_RED,"Error: Unknown player");
else
{
        if(IsVIP[plr] == 0)
        {
                            format(szMsg,256,"[VIP SYSTEM]: Admin %s made %s a V.I.P",gPlayers[playerid],gPlayers[plr]);
    SendClientMessageToAll(COLOR_YELLOW,szMsg);
    IsVIP[plr] = 1;
    /* data when specific here sends a "VIP"to a player */
}
else
{
           format(szMsg,256,"[VIP SYSTEM]: %s already have V.I.P Database", gPlayers[plr]);
           SendClientMessage(playerid,COLOR_LIGHT_RED,szMsg);
}
        }
}
else
{
SendClientMessage(playerid,COLOR_RED,"[VIP SYSTEM]: You are not authorized to use this command");
}
return 1;
    }
   
    else if(strcmp(cmd,"takevip",true) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
        tmp = strtok(cmdtext, idx);
        new plr = FindPlayerIDFromString(tmp);
if(!strlen(tmp)) SendClientMessage(playerid,COLOR_LIGHT_RED,"USAGE: /c takevip [Nick/ID]");
else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_LIGHT_RED,"Error: Unknown player");
else
{
      if(IsVIP[plr] == 1)
       {
           format(szMsg,256,"[VIP SYSTEM]: Admin %s took %s V.I.P privilegies",gPlayers[playerid],gPlayers[plr]);
           SendClientMessageToAll(COLOR_YELLOW,szMsg);
           IsVIP[plr] = 0;
           /* specific data here, taking away a "VIP"to a player */
     }
     else
     {
           format(szMsg,256,"[VIP SYSTEM]: %s is not in V.I.P Database", gPlayers[plr]);
           SendClientMessage(playerid,COLOR_LIGHT_RED,szMsg);
     }
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"[VIP SYSTEM]: You are not authorized to use this command");
}
return 1;
    }

I have tested and works, if you miss a detail, ,can which the command may not create what you want.

Remember to not put a "else if " and put down this "if".

I hope that works for you and greetings ;)
Title: Re: What is wrong ? VIP System
Post by: Madara on June 13, 2011, 02:08:39 am
if that solves your problem, should close the topic.
Title: Re: What is wrong ? VIP System
Post by: sseebbyy on June 13, 2011, 09:43:36 am
Thank You !  ;D

Work !