Gun "droping" system problems
#2

pawn Код:
enum GunData
{
    Object,         //Stores the object ID of the weapon
    Float:GunX,     //Stores the X coordinate of the weapon
    Float:GunY,     //Stores the Y coordinate of the weapon
    Float:GunZ      //Stores the Z coordinate of the weapon
};
new Shotgundrop[MAX_PLAYERS][GunData];  //Used to access the 'GunData' array with respect to 'playerid'.

CMD:dropgun(playerid, params[])
{
    if(IsValidDynamicObject(Shotgundrop[playerid][Object])) return SendClientMessage(playerid, -1, "You have already dropped a gun.");  //If they have already used /dropgun
    GetPlayerPos(playerid, Shotgundrop[playerid][GunX], Shotgundrop[playerid][GunY],Shotgundrop[playerid][GunZ]);
    Shotgundrop[playerid][Object] = CreateDynamicObject(2034, Shotgundrop[playerid][GunX], Shotgundrop[playerid][GunY],Shotgundrop[playerid][GunZ] - 0.9, 0, 0, 0.00);
    return 1;
}

CMD:pick(playerid, params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++) //Foreach is a better alternative
    {
        if(!IsPlayerConnected(i)) continue; //Remove if using Foreach.
        if(!IsValidDynamicObject(Shotgundrop[i][Object])) continue;
        if(!IsPlayerInRangeOfPoint(playerid, 2.0, Shotgundrop[i][GunX], Shotgundrop[i][GunY], Shotgundrop[i][GunZ])) continue;
        DestroyDynamicObject(Shotgundrop[i][Object]);
        Shotgundrop[i][Object] = -1;
        return 1;
    }
    SendClientMessage(playerid, -1, "There are no guns nearby."); //If there are no guns within 2.0 units of the player
    return 1;
}
References:
https://sampwiki.blast.hk/wiki/Scripting_Basics#Arrays
https://sampwiki.blast.hk/wiki/Keywords:Statements#for
Reply


Messages In This Thread
Gun "droping" system problems - by Supermaxultraswag - 22.03.2015, 10:51
Re: Gun "droping" system problems - by Threshold - 22.03.2015, 11:23
Re: Gun "droping" system problems - by Supermaxultraswag - 23.03.2015, 13:05
Re: Gun "droping" system problems - by Threshold - 23.03.2015, 13:18
Re: Gun "droping" system problems - by Supermaxultraswag - 23.03.2015, 16:27
Re: Gun "droping" system problems - by Threshold - 24.03.2015, 03:24
Re: Gun "droping" system problems - by Supermaxultraswag - 24.03.2015, 16:04
Re: Gun "droping" system problems - by Supermaxultraswag - 27.03.2015, 21:05
Re: Gun "droping" system problems - by Supermaxultraswag - 28.03.2015, 10:16
Re: Gun "droping" system problems - by Threshold - 28.03.2015, 12:54

Forum Jump:


Users browsing this thread: 1 Guest(s)