Little help
#1

I'm having trouble with a script where if a player has a barrel with them that they would lose it if they died or disconnected I am not sure how to do this can someone help me please?


Код:
public OnPlayerEnterCheckpoint(playerid)
{
    GivePlayerMoney(playerid, 10000);
    DisablePlayerCheckpoint(playerid);
    new name[MAX_PLAYER_NAME], string[44];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s has delivered a barrel.",name);
    SendClientMessageToAll(0xFFFF00AA, string);
	return 1;
}
Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == pickup1) SetPlayerCheckpoint(playerid, 1982.6150, -220.6680, -0.2432, 3.0);
	new name[MAX_PLAYER_NAME], string[44];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s has found a barrel.",name);
    SendClientMessageToAll(0xFFFF00AA, string);
	return 1;
}
Reply
#2

pawn Код:
new bool:HasBarrel[MAX_PLAYERS]; //On the top of your script

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == pickup1) SetPlayerCheckpoint(playerid, 1982.6150, -220.6680, -0.2432, 3.0);
    new name[MAX_PLAYER_NAME], string[44];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s has found a barrel.",name);
    SendClientMessageToAll(0xFFFF00AA, string);
    HasBarrel[playerid] = true;
    return 1;
}

public OnPlayerDeath(playerid,killerid,reason)
{
    if(HasBarrel[playerid] == true)
    {
        HasBarrel[playerid] = false;
        SendClientMessage(playerid,0xFF0000FF,"You lost the barrel!");
    }
    return 1;
}

if(HasBarrel[playerid] == true)  HasBarrel[playerid] = false; //Under OnPlayerDisconnect

public OnPlayerEnterCheckpoint(playerid)
{
    if(HasBarrel[playerid] == true)
    {
       GivePlayerMoney(playerid, 10000);
       DisablePlayerCheckpoint(playerid);
       new name[MAX_PLAYER_NAME], string[44];
       GetPlayerName(playerid, name, sizeof(name));
       format(string, sizeof(string), "%s has delivered a barrel.",name);
       SendClientMessageToAll(0xFFFF00AA, string);
       HasBarrel[playerid] = false;
       return 1;
    }
    else SendClientMessage(playerid,0xFFFF00AA,"You don't have a barrel!");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)