sscanf problem..
#7

pawn Код:
/* RNS V1.1 created by [iPs] Kreison */

// Defines
#define MAX_RBNPCS 16 // Max rob NPC number
#define NPC_PREFIX "Clerk" // NPC name prefix
#define NPC_SUFFIX "NLG" // NPC name suffix
#define ALARM_STOP 120 // Time to stop alarm (in secs) ~ TO TYPES 2 AND 3
#define ROB_INTERVAL 120 // Time interval to rob again after sucess (in secs)
#define FAILROB_INTERVAL 60 // Time interval to rob again after failure (in secs)


// Variables
// -- NPCs info
new assaltante[MAX_RBNPCS];
new robnpc[MAX_RBNPCS];
new robmax[MAX_RBNPCS];
new robmin[MAX_RBNPCS];
new robdelay[MAX_RBNPCS];
new robint[MAX_RBNPCS];
new npcnum;
// -- Timers
new timerrnpc[MAX_RBNPCS];
new timerrnpc2[MAX_RBNPCS];
new timerrplayer[MAX_RBNPCS];
// -- Configs
new ratp;
new sawd;



// Publics
forward roubop1(playerid, npcid);
public roubop1(playerid, npcid)
{
    ClearAnimations(npcid);
    timerrnpc[npcid] = SetTimerEx("roubop2", 100, false, "ii", playerid, npcid);
}


forward roubop2(playerid, npcid);
public roubop2(playerid, npcid)
{
    ClearAnimations(npcid);
    ApplyAnimation(npcid,"SHOP","SHP_Rob_GiveCash",4.1,0,1,1,1,0,1);
    timerrnpc[npcid] = SetTimerEx("roubop3", 3900, false, "ii", playerid, npcid);
}

forward roubop3(playerid, npcid);
public roubop3(playerid, npcid)
{
    KillTimer(timerrnpc2[npcid]);
    ClearAnimations(npcid);
    ApplyAnimation(npcid,"PED","DUCK_cower",4.1,1,1,1,1,1,1);
    PlayAlarm(npcid);
    assaltante[npcid] = INVALID_PLAYER_ID;
    robdelay[npcid] = 1;
    PayRobPlayer(playerid, npcid);
    SetTimerEx("RNDelay", ROB_INTERVAL*1000, false, "i", npcid);
}

forward PlayerStillAim(playerid, npcid);
public PlayerStillAim(playerid, npcid)
{
    new targetplayer = GetPlayerTargetPlayer(playerid);
    if (targetplayer != npcid)
    {
        ClearAnimations(npcid);
        ClearAnimations(npcid);
        assaltante[npcid] = INVALID_PLAYER_ID;
        KillTimer(timerrnpc[npcid]);
        KillTimer(timerrnpc2[npcid]);
        robdelay[npcid] = 1;

        SetTimerEx("RNDelay", FAILROB_INTERVAL*1000, false, "i", npcid);
        SetTimerEx("PlayerStillAim2", 100, false, "ii", playerid, npcid);
        CallLocalFunction("OnPlayerFailRob", "ii", playerid, npcid);
    }
}

forward PlayerStillAim2(playerid, npcid);
public PlayerStillAim2(playerid, npcid)
{
    ApplyAnimation(npcid,"PED","DUCK_cower",4.1,1,1,1,1,1,1);
    PlayAlarm(npcid);
}

forward StopAlarm(playerid);
public StopAlarm(playerid)
{
    PlayerPlaySound(playerid, 0, 0.0, 0.0, 0.0);
}

forward StopAlarmWhenIntChanged(playerid, npcid);
public StopAlarmWhenIntChanged(playerid, npcid)
{
    if(GetPlayerInterior(playerid) != robint[npcid])
    {
        PlayerPlaySound(playerid, 0, 0.0, 0.0, 0.0);
        KillTimer(timerrplayer[playerid]);
    }
}

forward RNDelay(npcid);
public RNDelay(npcid)
{
    robdelay[npcid] = 0;
}

forward AddRobNPC2(skin, Float:x, Float:y, Float:z, Float:ang, worldid, npcid);
public AddRobNPC2(skin, Float:x, Float:y, Float:z, Float:ang, worldid, npcid)
{
    SetPlayerPos(npcid, x, y, z);
    SetPlayerSkin(npcid, skin);
    SetPlayerVirtualWorld(npcid, worldid);
    SetPlayerFacingAngle(npcid, ang);

    ApplyAnimation(npcid,"SHOP","null",0.0,0,0,0,0,0);
    ApplyAnimation(npcid,"PED","null",0.0,0,0,0,0,0);
}



// Stocks
stock RandomEx(min, max)
{
    //Credits to ******
    new rand = random(max-min)+min;
    return rand;
}

stock IsPlayerInRangeOfPointEx(playerid, Float:range, Float:x, Float:y, Float:z, worldid)
{
    if (IsPlayerInRangeOfPoint(playerid, range, x, y, z) && GetPlayerVirtualWorld(playerid) == worldid)
    {
        return 1;
    }

    return 0;
}

stock PlayAlarm(npcid)
{
    new Float: x, Float: y, Float: z;
    GetPlayerPos(npcid, x, y, z);
   
    for (new i = 0; i <= npcnum;i++)
    {
        if (IsPlayerInRangeOfPointEx(i, 50.0, x, y, z, GetPlayerVirtualWorld(npcid)))
        {
            if (ratp == 0)
            {
                PlayerPlaySound(i, 3401, 0.0, 0.0, 0.0);
                timerrplayer[i] = SetTimerEx("StopAlarmWhenIntChanged", 500, true, "ii", i, npcid);
            } else if (ratp == 1) {
                PlayerPlaySound(i, 3401, x, y, z);
                timerrplayer[i] = SetTimerEx("StopAlarmWhenIntChanged", 500, true, "ii", i, npcid);
            } else if (ratp == 2) {
                PlayerPlaySound(i, 3401, 0.0, 0.0, 0.0);
                timerrplayer[i] = SetTimerEx("StopAlarm", ALARM_STOP*1000, false, "i", i);
            } else if (ratp == 3) {
                PlayerPlaySound(i, 3401, x, y, z);
                timerrplayer[i] = SetTimerEx("StopAlarm", ALARM_STOP*1000, false, "i", i);
            } else if (ratp == 4) {
                PlayerPlaySound(i, 3401, 0.0, 0.0, 0.0);
            } else if (ratp == 5) {
                PlayerPlaySound(i, 3401, x, y, z);
            }
        }
    }
}

stock CheckAimingRobNPC(playerid)
{
    new targetplayer = GetPlayerTargetPlayer(playerid);
   
    for (new x = 1; x <= npcnum; x++)
    {
        if(targetplayer == robnpc[x])
        {
            return robnpc[x];
        }
    }

    return INVALID_PLAYER_ID;
}

stock AddRobNPC(skin, Float:x, Float:y, Float:z, Float:ang, worldid, interiorid, min, max)
{
    npcnum++;
   
    new npcname[25];
    format(npcname, sizeof npcname, "%s%i_%s", NPC_PREFIX, npcnum, NPC_SUFFIX);
    robnpc[npcnum] = ConnectRNPC(npcname);

    assaltante[robnpc[npcnum]] = INVALID_PLAYER_ID;
   
    if(min > max) { printf("- Robbery NPCs system - WARNING: The minimum amount received by rob is bigger than the maximum!(NPC ID %i)", robnpc[npcnum]); }
    robmax[robnpc[npcnum]] = max;
    robmin[robnpc[npcnum]] = min;
    robint[robnpc[npcnum]] = interiorid;
   
    SetTimerEx("AddRobNPC2", 500, false, "iffffi", skin, Float:x, Float:y, Float:z, ang, worldid, robnpc[npcnum]);
}

stock SetAlarmType(num)
{
    if (num > 5)
    {
        ratp = 0;
        print("- Robbery NPCs system - WARNING: SetAlarmType was set to 0, because the type chosen is nonexistent.");
        return 0;
    }
   
    ratp = num;
    return 1;
}

stock StopAlarmOnDeath(num)
{
    if (num > 1)
    {
        sawd = 0;
        print("- Robbery NPCs system - WARNING: StopAlarmOnDeath was set to 0, because the option chosen is nonexistent.");
        return 0;
    }

    sawd = num;
    return 1;
}

stock PayRobPlayer(playerid, npcid)
{
    new moneyganho = RandomEx(robmin[npcid],robmax[npcid]);
    new rnmsg[35];
    format(rnmsg, sizeof rnmsg, "~g~You stole~n~$%i", moneyganho);
    GivePlayerMoney(playerid, moneyganho);
    GameTextForPlayer(playerid, rnmsg, 2000, 0);
    CallLocalFunction("OnPlayerSucessRob", "iii", playerid, npcid, moneyganho);
}



// Callbacks SA-MP

public OnPlayerConnect(playerid)
{
    #if defined RN_OnPlayerConnect
        RN_OnPlayerConnect(playerid);
    #endif
   
    ApplyAnimation(playerid,"SHOP","null",0.0,0,0,0,0,0);
    ApplyAnimation(playerid,"PED","null",0.0,0,0,0,0,0);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    #if defined RN_OnPlayerDeath
        RN_OnPlayerDeath(playerid, killerid, reason);
    #endif

    if (sawd) { StopAlarm(playerid); }

    return 1;
}



// Hooks
#if defined _ALS_OnPlayerUpdate
    #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif
#define OnPlayerUpdate RN_OnPlayerUpdate
#if defined RN_OnPlayerUpdate
    forward RN_OnPlayerUpdate(playerid);
#endif

#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect RN_OnPlayerConnect
#if defined RN_OnPlayerConnect
    forward RN_OnPlayerConnect(playerid);
#endif

#if defined _ALS_OnPlayerDeath
    #undef OnPlayerDeath
#else
    #define _ALS_OnPlayerDeath
#endif
#define OnPlayerDeath RN_OnPlayerDeath
#if defined RN_OnPlayerDeath
    forward RN_OnPlayerDeath(playerid, killerid, reason);
#endif



// Callbacks of include
forward OnPlayerSucessRob(playerid, npcid, value);
forward OnPlayerFailRob(playerid, npcid);
Reply


Messages In This Thread
sscanf problem.. - by Don_Cage - 02.02.2014, 08:07
Re: sscanf problem.. - by CuervO - 02.02.2014, 08:20
Re: sscanf problem.. - by Don_Cage - 02.02.2014, 08:25
Re: sscanf problem.. - by CuervO - 02.02.2014, 08:28
Re: sscanf problem.. - by PAF - 02.02.2014, 08:54
Re: sscanf problem.. - by iZN - 02.02.2014, 09:00
Re: sscanf problem.. - by Don_Cage - 02.02.2014, 09:13
Re: sscanf problem.. - by iZN - 02.02.2014, 09:25
Re: sscanf problem.. - by Don_Cage - 02.02.2014, 09:40
Re: sscanf problem.. - by iZN - 02.02.2014, 09:59

Forum Jump:


Users browsing this thread: 3 Guest(s)