SA-MP Forums Archive
Object not showing up - 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: Object not showing up (/showthread.php?tid=388860)



Object not showing up - NoahF - 30.10.2012

When I type /slenderon, everything works, it's just that the object will not show up behind my player. Also, could someone add where every 3 seconds the object is destroyed but gets created again, with the players new position? Thanks.
CODE:

Код:
#include <a_samp>
#include <zcmd>
#define FILTERSCRIPT
#define COLOR_RED 0xFF0000C8

new object;
new Float:pCoo[3];
new SwitchPlayerTimer_;
new DestroyObjectTimer1_;
forward DestroyObjectTimer();
forward SwitchPlayer(playerid);
forward SwitchPlayerTimer();
forward DestroyObjectTimer1();

public OnFilterScriptInit()
{
    print("______________________________________________________________________________");
    print("|");
    print("NoahF's Slender FilterScript has successfully loaded! Beware of Slender..");
    print("|");
    print("______________________________________________________________________________");
    return 1;
}

public OnFilterScriptExit()
{
    print("______________________________________________________________________________");
    print("|");
    print("NoahF's Slender FilterScript has successfully loaded! Beware of Slender..");
    print("|");
    print("______________________________________________________________________________");
    return 1;
}

public DestroyObjectTimer1()
{
    DestroyObject(object);
    return 1;
}

public SwitchPlayer(playerid)
{
    SelectRandomPlayer();
    GetPlayerPos(playerid, pCoo[0],pCoo[1],pCoo[2]);
    object = CreateObject(2589, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    AttachObjectToPlayer(object, playerid, 10.0, 10.0, 1.5, 0.0, 0.0, 0.0);
    DestroyObjectTimer1_=SetTimer("DestroyObjectTimer1", 5000, true);
    SwitchPlayerTimer_=SetTimer("SwitchPlayerTimer", 183333, true);
    return 1;
}

public SwitchPlayerTimer()
{
    SelectRandomPlayer();
    return 1;
}

stock SelectRandomPlayer()
{
     new r = random(MAX_PLAYERS);
     if(IsPlayerConnected®)
     {
           return r;
     }
     else
     {
           SelectRandomPlayer();
     }
     return 1;
}

COMMAND:slenderon(playerid, params[])
{
    #pragma unused params
    if(IsPlayerAdmin(playerid))
    {
        SendClientMessage(playerid,COLOR_RED, "Slender mode ON! You better start running, and don't look behind you! :)");
        SelectRandomPlayer();
        SendClientMessageToAll(COLOR_RED, "Slender Mode has been Activated for everyone. Always look behind you..");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            PlayAudioStreamForPlayer(playerid, "http://soundcloud.com/noahfallon/slender-music-40-minutes-long/download");
            return 1;
        }
    }
    return 1;
}

COMMAND:slenderoff(playerid, params[])
{
    #pragma unused params
    if(IsPlayerAdmin(playerid))
    {
        SendClientMessage(playerid,COLOR_RED, "Slender mode OFF! You are safe now! :)");
        DestroyObject(object);
        KillTimer(SwitchPlayerTimer_);
        KillTimer(DestroyObjectTimer1_);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            StopAudioStreamForPlayer(playerid);
            return 1;
        }
    }
    return 1;
}



AW: Object not showing up - Skimmer - 30.10.2012

This variables should have an array for every players.

Код:
new object[MAX_PLAYERS];
new Float:pCoo[MAX_PLAYERS][3];
new SwitchPlayerTimer_[MAX_PLAYERS];
new DestroyObjectTimer1_[MAX_PLAYERS];
Код:
public SwitchPlayer(playerid)
{
    SelectRandomPlayer();
    GetPlayerPos(playerid, pCoo[playerid][0],pCoo[playerid][1],pCoo[playerid][2]);
    object[playerid] = CreateObject(2589, pCoo[playerid][0], pCoo[playerid][1], pCoo[playerid][2], 0.0, 0.0, 0.0);
    AttachObjectToPlayer(object, playerid, 10.0, 10.0, 1.5, 0.0, 0.0, 0.0);
    DestroyObjectTimer1_[playerid]=SetTimerEx("DestroyObjectTimer1", 5000, true, "i", playerid);
    SwitchPlayerTimer_[playerid]=SetTimerEx("SwitchPlayerTimer", 183333, true, "i", playerid);
    return 1;
}



Re: Object not showing up - Bakr - 30.10.2012

You never call the SwitchPlayer function, which creates the object and timer. I believe you may be confusing that function name with SelectRandomPlayer. If not, then your SelectRandomPlayer function is useless, as you don't assign it anywhere in the script when calling it. There are a few other problems with your script, but I'll leave you to settle them out. It's all about experimenting that will enable you to not fall into this situation next time.

EDIT: ^ That is why I hate these forums!


Re: Object not showing up - NoahF - 31.10.2012

Ok. Thanks.