Command needed
#1

I need a command for RP script for the taxi job...

When i do /counter on it will take 2 dollars every 5 seconds from the guy who siting in my taxi

and when i do /counter off it'll stop.

Thx for the helpers...
Reply
#2

please help with this...
Reply
#3

Havent tested it, but should work

pawn Код:
new PayTime[MAX_PLAYERS];
new InTaxi[MAX_PLAYERS];

public OnPlayerExitVehicle(playerid, vehicleid) {

  if(InTaxi[playerid] == 1) KillTimer(PayTime[playerid]);
  return 1;
}
   
public OnPlayerCommandText(playerid, cmdtext[]) {

  if(strcmp(cmdtext,"/counter",true) == 0) {
    new tmp[256], idx; tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) {
      new taxi = GetPlayerVehicleID(playerid);
      for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && IsPlayerInVehicle(i, taxi) && i != playerid) {
          PayTime[i] = SetTimerEx("Pay", 5000, 0, "ii", playerid, i);
          InTaxi[i] = 1;
        }
      }
    }
    else if(strcmp(tmp, "off", true) == 0) {
      new taxi = GetPlayerVehicleID(playerid);
      for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && IsPlayerInVehicle(i, taxi) && i != playerid) {
          KillTimer(PayTime[i]);
          InTaxi[i] = 0;
        }
      }
    }
    return 1;
  }
 
  return 0;
}

forward Pay(playerid, passenger);
public Pay(playerid, passenger) {

  if(GetPlayerMoney(passenger) >= 2) {
    GivePlayerMoney(passenger, -2);
    GivePlayerMoney(playerid, 2);
    PayTime[passenger] = SetTimerEx("Pay", 5000, 0, "ii", playerid, passenger);
  }else{
    RemovePlayerFromVehicle(passenger);
    SendClientMessage(playerid, WHITE, "You have been kicked from taxi..");
  }
}
You should also add InTaxi[playerid] = 0; OnPlayerConnect

Have fun
Reply
#4

I got those warnings..

Код:
C:\Documents and Settings\Yarik\Desktop\CD-Disabler 1.2\one of the best edits\gamemodes\crp.pwn(2111) : warning 219: local variable "tmp" shadows a variable at a preceding level
C:\Documents and Settings\Yarik\Desktop\CD-Disabler 1.2\one of the best edits\gamemodes\crp.pwn(2111) : warning 219: local variable "idx" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
Line 2111
Код:
    new tmp[256], idx; tmp = strtok(cmdtext, idx);
Reply
#5

delete this
Код:
new tmp[256], idx;
Have fun
Reply
#6

Okay thats nice -.-

Код:
C:\Documents and Settings\Yarik\Desktop\CD-Disabler 1.2\one of the best edits\gamemodes\crp.pwn(2238) : warning 219: local variable "tmp" shadows a variable at a preceding level
C:\Documents and Settings\Yarik\Desktop\CD-Disabler 1.2\one of the best edits\gamemodes\crp.pwn(2238) : warning 219: local variable "idx" shadows a variable at a preceding level
C:\Documents and Settings\Yarik\Desktop\CD-Disabler 1.2\one of the best edits\gamemodes\crp.pwn(2238) : warning 203: symbol is never used: "idx"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Reply
#7

deleted wrong one?
Reply
#8

Okay now i entered the server after i fixed the warnings and errors ...

my friend entered the car i did /counter and nothing happend -.-

i didnt get any cash and he didnt get any -2 dollars...........
Reply
#9

Any one else can help with it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)