A little scripting help
#1

Well i added the timer as you might see at bottom but when im ingame it doesent show after droping the car. So basicly im spamming /dropcar at the checkpoint and i am getting payed. And how to make the car to dissapier after entering the checkpoint ?
PHP код:
CMD:dropcar(playeridparams[])
{
    if(
GetPlayerVehicleID(playerid) != 0)
    {
        
DisablePlayerCheckpoint(playerid);
        
SetPlayerCheckpoint(playerid2505.8506, -2629.014413.29445);
        
SendClientMessage(playeridCOLOR_LIGHTBLUE"Drop the car at the crane!");
        
dropping[playerid] = true;
    }
    return 
1;

PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
        if(
dropping[playerid] == true)
        {
            
DisablePlayerCheckpoint(playerid);
            new 
string[128], price;
            
price random (100);
            
format(stringsizeof(string), "*You've earned {FF6347}$%d{33CCFF} from dropping a car!"price);
            
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
            
GivePlayerMoney(playeridprice);
            
dropping[playerid] = false;
            
SetTimerEx("DropTimer"20000false"i"playerid);
        } 
Reply
#2

pawn Код:
new dropping[MAX_PLAYERS]; //At the top of your script

public OnPlayerConnect(playerid)
{
    dropping[playerid] = INVALID_VEHICLE_ID;
    //Rest of code...
    return 1;
}

CMD:dropcar(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(!vehicleid) return SendClientMessage(playerid, 0xFF0000FF, "You must be inside a vehicle to use this command.");
    DisablePlayerCheckpoint(playerid);
    SetPlayerCheckpoint(playerid, 2505.8506, -2629.0144, 13.2944, 5);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "Drop the car at the crane!");
    dropping[playerid] = vehicleid;
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    new vid = GetPlayerVehicleID(playerid);
    if(dropping[playerid] == vid && vid != INVALID_VEHICLE_ID)
    {
        DisablePlayerCheckpoint(playerid);
        new string[60], price = random(100);
        format(string, sizeof(string), "*You've earned {FF6347}$%d{33CCFF} from dropping a car!", price);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        GivePlayerMoney(playerid, price);
        dropping[playerid] = INVALID_VEHICLE_ID;
        SetTimerEx("DropTimer", 20000, false, "i", playerid);
        DestroyVehicle(vid);
    }
    //rest of code...
    return 1;
}
If you want the vehicle to respawn rather than be destroyed, change DestroyVehicle to SetVehicleToRespawn.
Reply
#3

Quote:
Originally Posted by Threshold
Посмотреть сообщение
pawn Код:
new dropping[MAX_PLAYERS]; //At the top of your script

public OnPlayerConnect(playerid)
{
    dropping[playerid] = INVALID_VEHICLE_ID;
    //Rest of code...
    return 1;
}

CMD:dropcar(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
        if(!vehicleid) return SendClientMessage(playerid, COLOR_GREY, "You must be inside a vehicle to use this         command.");
    DisablePlayerCheckpoint(playerid);
    SetPlayerCheckpoint(playerid, 2505.8506, -2629.0144, 13.2944, 5);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "Drop the car at the crane!");
    dropping[playerid] = vehicleid;
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    new vid = GetPlayerVehicleID(playerid);
    if(dropping[playerid] == vid && vid != INVALID_VEHICLE_ID)
    {
        DisablePlayerCheckpoint(playerid);
        new string[60], price = random(100);
        format(string, sizeof(string), "*You've earned {FF6347}$%d{33CCFF} from dropping a car!", price);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        GivePlayerMoney(playerid, price);
        dropping[playerid] = INVALID_VEHICLE_ID;
        SetTimerEx("DropTimer", 20000, false, "i", playerid);
        DestroyVehicle(vid);
    }
    //rest of code...
    return 1;
}
If you want the vehicle to respawn rather than be destroyed, change DestroyVehicle to SetVehicleToRespawn.

So basicly i fixed the issue with car not respawning and the pay after delivering but i have problem with the timer its not being set after delivery and i can spam the cmd ;/

PHP код:
//Dropcar
new DropTime[MAX_PLAYERS];
new 
bool:dropping[MAX_PLAYERS]; 
PHP код:
//Public variables
DropTime[playerid] = 0
PHP код:
CMD:dropcar(playeridparams[])
{
    new 
string[128];
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    if(!
vehicleid) return SendClientMessage(playeridCOLOR_LIGHTBLUE"You must be inside a vehicle to use this command.");
    else if(
dropping[playerid] == false)
    {
        
format(stringsizeof(string), "You need to wait {FF6347}%d{33CCFF} more seconds before doing dropcar again."DropTime[playerid]);
        
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
    }
    if(
GetPlayerVehicleID(playerid) != 0)
    {
        
DisablePlayerCheckpoint(playerid);
        
SetPlayerCheckpoint(playerid2505.8506, -2629.014413.29445);
        
SendClientMessage(playeridCOLOR_LIGHTBLUE"Deliver car to the Los Santos Docks!");
        
dropping[playerid] = true;
    }
    return 
1;

PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
        if(
dropping[playerid] == true)
        {
            
DisablePlayerCheckpoint(playerid);
            new 
vehicleid GetPlayerVehicleID(playerid);
            new 
string[128], playerbamount;
            
amount random (100);
            
format(stringsizeof(string), "*You've earned {FF6347}$%d{33CCFF} from dropping a car!"amount);
            
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
            
GiveDodMoney(playerbamount);
            
SetVehicleToRespawn(vehicleid);
            
dropping[playerid] = true;
            
DropTime[playerid] = 60*20;
            
SetTimerEx("DropcarTime"1000false"i"playerid);
            
            
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)