SA-MP Forums Archive
Little help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Little help (/showthread.php?tid=291198)



Little help - muhib777 - 18.10.2011

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;
}



Re: Little help - AeroBlast - 18.10.2011

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;
}