if(strcmp("/takejob", cmdtext, true) == 0) { if IsPlayerInVehicle(playerid,420) *then SendClientMessage(playerid, 0xFFFFFFFF, "You're now a taxidriver!"); //and what whe have to do as driver! else SendClientMessage(playerid, 0xFFFFFFFF, "You cannot work in this vehicle"); } return 1; }
IsPlayerInVehicle(playerid,420)
IsPlayerInVehicle(playerid, vehicleid); // vehicleid is the ID of the vehicle, not the model of the vehicle.
if(strcmp("/takejob", cmdtext, true) == 0)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 420) return SendClientMessage(playerid, 0xFFFFFFFF, "You cannot work in this vehicle");
SendClientMessage(playerid, 0xFFFFFFFF, "You're now a taxidriver!");
return 1;
}
Thanks it works !
But i have one question where can i put the code what's happening when they are a taxi drive? Before return 1; ? |
new IsDriver[MAX_PLAYERS]; // You may replace this with the system you are currently using.
forward DrivePay(playerid);
for(new i = 0; i < MAX_PLAYERS; i++) // A loop. Instead of a loop I actually suggest you to use foreach. But for this moment, let's use a loop.
{
if(IsPlayerConnected(i)) // Check if the player is connected.
{
SetTimerEx("DrivePay", 60000, true, "i", i);
}
}
if(strcmp("/takejob", cmdtext, true) == 0)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 420) return SendClientMessage(playerid, 0xFFFFFFFF, "You cannot work in this vehicle");
if(IsDriver[playerid] == 1) return SendClientMessage(playerid, 0xFFFFFFFF, "You are already a driver."); //You may repalce this variable with the system you are currently using.
SendClientMessage(playerid, 0xFFFFFFFF, "You're now a taxidriver!");
IsDriver[playerid] = 1; // Make the player a driver. // You may replace this variable with the system you are currently using.
return 1;
}
public DrivePay(playerid)
{
if(IsDriver[playerid] == 1 && GetVehicleModel(GetPlayerVehicleID(playerid)) == 240 )
{
GivePlayerMoney(playerid, 800);
}
return 1;
}
Oke another question right now
![]() I dont get it with timers! But i want when a player drive in vehicle 420 that they every minute earn $800 But when they leave that vehicle they dont earn anything.. Can anyone help me.? I wanted to figure it out by myself but it doesn't work! |
//On Top
new taxitimer[MAX_PLAYERS];
if(strcmp("/takejob", cmdtext, true) == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 420) return SendClientMessage(playerid, 0xFFFFFFFF, "You cannot work in this vehicle
{
SendClientMessage(playerid, 0xFFFFFFFF, "You're now a taxidriver!");
taxitimer[playerid] = SetTimerEx("taxitimer",60000,true,"i", i);
}
}
return 1;
}
//Somewhere in script
foward taxitimer(playerid)
public taxitimer(playerid)
{
GivePlayerMoney(playerid, 800);
if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 420)
{
KillTimer(taxitimer);
}
return 1;
}
No it won't. You've set a regular timer. You have to set a timer 'EX' for playerid.
Also, your function to give the money fails a lot. Givemoney to killerid but you defined playerid? You didn't return? |
It works
![]() But players dont get payed : dat gaat over die van @biesman (aangezien hij ook nederlands is) That other one i have to test! |
It works
![]() But players dont get payed : dat gaat over die van @biesman (aangezien hij ook nederlands is) That other one i have to test! |
It doesn't work, you can't set a normal timer on a function which is for players.
He should use SetTimerEx. @ The new script from nejc. That's better, but you don't really know the SetTimerEx function, do you? ![]() You made the timer only work for players with the player ID 1337. |
SetTimer("DrivePay", 60000, true);
public DrivePay()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetVehicleModel(GetPlayerVehicleID(i)) == 420)
{
GivePlayerMoney(i, 800);
}
}
}
}