Command Problem
#1

(Sry for bad English! )
I created a CMD
if(strcmp(cmd,"/tanken",true)==0)
{
if(TankStation(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerMoney(playerid) > 2)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,FARBE_WEIЯ,"Benutzung: Benutze /tanken [menge]");
return 1;
}
new setin = strval(tmp);
new summe = strval(tmp);
new tString[64];
TogglePlayerControllable(playerid,0);
GivePlayerMoney(playerid,-setin*2);
format(tString,sizeof(tString),"Du Tankst %d Liter und bezahlst dafьr $%d.",setin,summe*2);
SendClientMessage(playerid,FARBE_GRЬN,tString);
SetTimerEx("TankZeit",2000,0, "dd", playerid, setin);
return 1;
}
else if(LimitTest >= 101)
{
SendClientMessage(playerid,FARBE_WEIЯ,"Du kanntst nicht ьber 100 Liter tanken!");
TogglePlayerControllable(playerid,1);
return 1;
}
else
{
SendClientMessage(playerid,FARBE_WEIЯ,"Du brauchst mindestens 2$ um zu tanken!");
}
}
else
{
SendClientMessage(playerid,FARBE_WEIЯ,"Du sitz nicht in einem Fahrzeug!");
}
}
else
{
SendClientMessage(playerid,FARBE_WEIЯ,"Du bist nicht an einer Tankstelle oder nicht nah genug dran!");
}
}
return 1;
}
This is my / fill CMD,
I have it set up so that if I for example 95 liters of gasoline and
/tanken 6 write, then my car will be refueled, but I'm there
else if(LimitTest >= 101)
{
SendClientMessage(playerid,FARBE_WEIЯ,"You knew not fill up more than 100 liters!");
TogglePlayerControllable(playerid,1);
return 1;
}
installed, it should get the text that I can not fill up more than 100 liters of petrol, but will fill up my car and my money will be deducted.

I hope someone can help me: (
Reply
#2

so is the command used like? /tank liters? if so then strval(tmp); // will = the liters so
pawn Код:
else if(strval(tmp) >= 101)
      {
        SendClientMessage(playerid,FARBE_WEIЯ,"Du kanntst nicht ьber 100 Liter tanken!");
        TogglePlayerControllable(playerid,1);
        return 1;
      }
etc that help?
Reply
#3

thanks for the answer, but unfortunately does not work
Reply
#4

take the else out
pawn Код:
if(strcmp(cmd,"/tanken",true)==0)
{
  if(TankStation(playerid))
  {
   if(IsPlayerInAnyVehicle(playerid))
    {
      tmp = strtok(cmdtext, idx);
      new setin = strval(tmp);
      if(GetPlayerMoney(playerid) < 2*setin){
        SendClientMessage(playerid,FARBE_WEIЯ,"Du brauchst mindestens 2$ um zu tanken!"); //2 bucks a liter
        return 1;
          }
      if(!strlen(tmp))
       {
         SendClientMessage(playerid,FARBE_WEIЯ,"Benutzung: Benutze /tanken [menge]");
          return 1;
       }
      if(setin >= 101 || setin =< 0)
      {
        SendClientMessage(playerid,FARBE_WEIЯ,"Du kanntst nicht ьber 100 Liter tanken!"); //more or less than 1-100
        TogglePlayerControllable(playerid,1);
        return 1;
      }
      new summe = strval(tmp);
      new tString[64];
      TogglePlayerControllable(playerid,0);
      GivePlayerMoney(playerid,-setin*2);
      format(tString,sizeof(tString),"Du Tankst %d Liter und bezahlst dafьr $%d.",setin,summe*2);
      SendClientMessage(playerid,FARBE_GRЬN,tString); //give x amount of petrol
      SetTimerEx("TankZeit",2000,0, "dd", playerid, setin);
      return 1;
      }
     
     
     }
     else
     {
       SendClientMessage(playerid,FARBE_WEIЯ,"Du sitz nicht in einem Fahrzeug!");//not in car?
       return 1;
     }
   }
   else
   {
     SendClientMessage(playerid,FARBE_WEIЯ,"Du bist nicht an einer Tankstelle oder nicht nah genug dran!");//not at station
     return 1;
   }
  }
  return 1
}
how about that?
Reply
#5

Код:
C:\Users\Schnacke\Desktop\LSR SM\gamemodes\LSR-Selfmade.pwn(175) : warning 211: possibly unintended assignment
C:\Users\Schnacke\Desktop\LSR SM\gamemodes\LSR-Selfmade.pwn(175) : error 022: must be lvalue (non-constant)
C:\Users\Schnacke\Desktop\LSR SM\gamemodes\LSR-Selfmade.pwn(175) : error 029: invalid expression, assumed zero
C:\Users\Schnacke\Desktop\LSR SM\gamemodes\LSR-Selfmade.pwn(175) : warning 215: expression has no effect
C:\Users\Schnacke\Desktop\LSR SM\gamemodes\LSR-Selfmade.pwn(175) : error 001: expected token: ";", but found ")"
C:\Users\Schnacke\Desktop\LSR SM\gamemodes\LSR-Selfmade.pwn(175) : fatal error 107: too many error messages on one line

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


4 Errors.
if(setin >= 101 || setin =< 0) //The Error
with && it does not
Reply
#6

try

if(setin >= 101 || setin <= 0) //The fix

&& will never be true (greater than 100 and les then 1
Reply
#7

hmmmmmm
It does not work: (I still get my gasoline
Reply
#8

if its over 100 hmm?

do you need to check how much is in the tank already so it dont go over 100? or are you just going /tanken 200 or something
Reply
#9

I've tried it with 100 and 101, is not working
Reply
#10

100 should work 101 shouldnt

can i see the timer "TankZeit"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)