[HELP] /dropcar
#1

Hi, I made a custom /dropcar cmd but when I'm going to use /dropcar ID it always say: "This vehicle doesn't belong to that player!"
Here's the code:
Код:
  if(strcmp(cmd,"/dropcar", true) == 0)
  {
  if(PlayerInfo[playerid][pMember] == 16 || PlayerInfo[playerid][pLeader] == 16)
  {
   tmp = strtok(cmdtext, idx);
	 new playa;
	 playa = ReturnUser(tmp);
   new carid = GetPlayerVehicleID(playerid);
   new LoL = GetPlayerName(playa,gname,sizeof(gname));
   if(!strlen(tmp))
	 {
	 SendClientMessage(playerid, COLOR_GRAD2, "USE: /dropcar [playerid/PartOfName]");
	 return 1;
	 }
   if(IsAnOwnableCar(carid))
   {
   if(LoL == CarInfo[carid][cOwner])
   {
	  SetTimerEx("RubaVeicolo",300000, false, "i", playerid);
	  SendClientMessage(playerid,COLOR_WHITE, "* Stai rubando l'auto, devi rimanere dentro per 5 minuti!");
	  GetPlayerName(playerid,gname,sizeof(gname));
	  format(gstring,sizeof(gstring),"* %s apre il pannello dell'auto e inizia a smontarlo.",gname);
    ProxDetector(30.0, playerid, gstring, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
   }
   else return SendClientMessage(playerid,COLOR_WHITE,"* This vehicle doesn't belong to that player!");
  }
  else return SendClientMessage(playerid,COLOR_WHITE,"* This vehicle is not owned!");
  }
  else return SendClientMessage(playerid,COLOR_WHITE,"* You are not a the Ombre member!");
  return 1;
 }
Please help!
Reply
#2

Hello,

There were a couple of things incorrect:

pawn Код:
new LoL = GetPlayerName(playa,gname,sizeof(gname));
should just be:
pawn Код:
new gname[MAX_PLAYER_NAME];
GetPlayerName(playa,gname,sizeof(gname));
Another thing I changed was:
pawn Код:
if(LoL == CarInfo[carid][cOwner])
to
pawn Код:
if(strcmp(gname, CarInfo[carid][cOwner], true) == 0)
This should hopefully work:
pawn Код:
if(strcmp(cmd,"/dropcar", true) == 0)
{
    if(PlayerInfo[playerid][pMember] == 16 || PlayerInfo[playerid][pLeader] == 16)
    {
        tmp = strtok(cmdtext, idx);
        new playa, gname[MAX_PLAYER_NAME];
        playa = ReturnUser(tmp);
        new carid = GetPlayerVehicleID(playerid);
        GetPlayerName(playa,gname,sizeof(gname));
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "USE: /dropcar [playerid/PartOfName]");
            return 1;
        }
        if(IsAnOwnableCar(carid))
        {
            if(strcmp(gname, CarInfo[carid][cOwner], true) == 0)
            {
                SetTimerEx("RubaVeicolo",300000, false, "i", playerid);
                SendClientMessage(playerid,COLOR_WHITE, "* Stai rubando l'auto, devi rimanere dentro per 5 minuti!");
                format(gstring,sizeof(gstring),"* %s apre il pannello dell'auto e inizia a smontarlo.",gname);
                ProxDetector(30.0, playerid, gstring, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            else return SendClientMessage(playerid,COLOR_WHITE,"* This vehicle doesn't belong to that player!");
        }
        else return SendClientMessage(playerid,COLOR_WHITE,"* This vehicle is not owned!");
    }
    else return SendClientMessage(playerid,COLOR_WHITE,"* You are not a the Ombre member!");
    return 1;
}

Reply
#3

For the gname, I already defined it at top of the script. Thanks anyway I'm gonna test it!
EDIT: It works great! Thank you!
Reply
#4

Quote:
Originally Posted by Zimon95
For the gname, I already defined it at top of the script. Thanks anyway I'm gonna test it!
EDIT: It works great! Thank you!
Good to hear, you're welcome.
Reply
#5

I have errors.

C:\Users\Martins un citi\Desktop\ser 0.3\gamemodes\larp.pwn(46779) : error 017: undefined symbol "gname"
C:\Users\Martins un citi\Desktop\ser 0.3\gamemodes\larp.pwn(46779) : error 017: undefined symbol "gname"
C:\Users\Martins un citi\Desktop\ser 0.3\gamemodes\larp.pwn(46779) : error 029: invalid expression, assumed zero
C:\Users\Martins un citi\Desktop\ser 0.3\gamemodes\larp.pwn(46779) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)