Jump to content
  • 0

Problema getgift


ValyYouTube

Question

Salut am o problema la/ getgift poti sa dai de cate ori vrei iar eu vreau sa  o fac sa poti da odata la o zi cine ma poate ajuta?

#include            <a_samp>
#include            <streamer>
#include            <sscanf2>
#include            <zcmd>
#define COLOR_YELLOW 0xFFFFFFC8
#define COLOR_RED 0xFF0000C8

#define MAX_RANDOM_GIFTS 4

public OnFilterScriptInit()
{
    return 1;
}

#pragma tabsize 0


stock RandomGift(playerid)
{
    new randomgift = random(MAX_RANDOM_GIFTS) + 1;
    switch (randomgift)
    {
        case 1:
        {
            GivePlayerMoney(playerid, 500000);
            SendClientMessage(playerid, COLOR_YELLOW, "Ai primt de la gift 500000$!");
        }
        case 2:
        {
            GivePlayerMoney(playerid, 10000);
            SendClientMessage(playerid, COLOR_YELLOW, "Ai primit de la gift 10000$!");
        }
        case 3:
        {
            SetPlayerScore(playerid, 4);
            SendClientMessage(playerid, COLOR_YELLOW, "Ai primit level up +4");
        }
        case 4:
        {
            SendClientMessage(playerid, COLOR_YELLOW, "Nu ai primit nimic!imi pare rau.");
        }
    }
    return 1;
}


new Float:giftPos[4];
new giftboxobject;
new giftboxcreated = 0;
new Text3D:giftbox3DText;


CMD:giftbox(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not an admin!");
    if (isnull(params))
     {
         SendClientMessage(playerid, -1, "/giftbox [Option]");
        SendClientMessage(playerid, COLOR_YELLOW, "[OPTIONS]: place, destroy");
        return 1;
    }
    static
        Float:X,
        Float:Y,
        Float:Z,
        Float:A;

    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);

    if (!strcmp(params, "place", true))
    {
        if (IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid, COLOR_RED, "You must be outside vehicle first.");
        if(giftboxcreated == 1) return SendClientMessage(playerid, COLOR_RED, "Giftbox is already placed.");
            giftPos[0] = X;
            giftPos[1] = Y;
            giftPos[2] = Z;
            giftboxcreated = 1;
            giftboxobject = CreateDynamicObject(19054, X, Y, Z - 0.4, 0.0, 0.0, A);
            giftbox3DText = CreateDynamic3DTextLabel("/getgift\nTo get your gift.",0x10F441AA,X, Y, Z+0.25,8.0);
            SendClientMessage(playerid, -1, "You have placed a giftbox");
            return 1;
    }
    
    if (!strcmp(params, "destroy", true))
    {
     if(giftboxcreated == 0) return SendClientMessage(playerid, COLOR_RED, "Giftbox is not placed yet.");
            DestroyDynamicObject(giftboxobject);
            DestroyDynamic3DTextLabel(giftbox3DText);
            giftboxcreated = 0;
            SendClientMessage(playerid, -1, "You have destoryed the giftbox");
            return 1;
    }
    return 1;
}

CMD:getgift(playerid)
{
    if(!IsPlayerConnected(playerid))
        return SendClientMessage(playerid, -1, "You must be logged in to do this.");

    GetObjectPos(giftboxobject, giftPos[0], giftPos[1], giftPos[2]);
    
    if(IsPlayerInRangeOfPoint(playerid, 5.0, giftPos[0], giftPos[1], giftPos[2]) && giftboxcreated == 1)
    {
    RandomGift(playerid);
    }
    return 1;
}

  • Upvote 1
Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

Salut,

Daca vrei s-o faci doar sa se poata folsi o singura data pe zi trebuie sa ai o variabila pe jucator care sa retina ultima timpul pana cand poate sa o foloseasca iar sau alta varianta daca vrei sa se poata da fix dupa ora 00 este sa memorezi timpul cand a executat comanda si sa verifici daca cand a executat-o iar este trecut de ora 00. Verificarea o faci in comanda /getgift.

Link to comment
Share on other sites

  • 0

imi poti lasa codul te rog

 

12 minutes ago, WopsS said:

Salut,

Daca vrei s-o faci doar sa se poata folsi o singura data pe zi trebuie sa ai o variabila pe jucator care sa retina ultima timpul pana cand poate sa o foloseasca iar sau alta varianta daca vrei sa se poata da fix dupa ora 00 este sa memorezi timpul cand a executat comanda si sa verifici daca cand a executat-o iar este trecut de ora 00. Verificarea o faci in comanda /getgift.

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

O sa-ti las un mic "tutorial", restul o sa-l aplici tu.

Mai intai trebuie sa faci o variabila pentru toti jucatorii in care sa stochezi daca cand a luat cadoul, asta o sa arate cam asa

new GiftTakenTime[MAX_PLAYERS]; // Initializezi un vector cu numarul maxim de jucatori care pot fi suportati simultan.

dupa care o sa trebuiasca sa faci verificarea si atribuirea, care o sa arate cam asa

if (GiftTakenDate[playerid] > gettime()) // Verifici daca au trecut 24 de ore sau nu in momentul in care se executa comanda.
{
	return SendClientMessage(playerid, -1, "Ai luat deja cadoul, revin-o mai tarziu.");
}

// Codul tau daca trece de verificarea de mai sus.

GiftTakenDate[playerid] = gettime() + 86400; // Atribui valoarea variabilei adunand 86400 (86400 = 24 de ore in secunde) la timpul curent.
Link to comment
Share on other sites

  • 0
12 minutes ago, WopsS said:

asta trebuie sa al pun si atat

daca da Mersi 


new GiftTakenTime[MAX_PLAYERS]; // Initializezi un vector cu numarul maxim de jucatori care pot fi suportati simultan.

dupa care o sa trebuiasca sa faci verificarea si atribuirea, care o sa arate cam asa


if (GiftTakenDate[playerid] > gettime()) // Verifici daca au trecut 24 de ore sau nu in momentul in care se executa comanda.
{
	return SendClientMessage(playerid, -1, "Ai luat deja cadoul, revin-o mai tarziu.");
}

// Codul tau daca trece de verificarea de mai sus.

GiftTakenDate[playerid] = gettime() + 86400; // Atribui valoarea variabilei adunand 86400 (86400 = 24 de ore in secunde) la timpul curent.

 

  • Upvote 1
Link to comment
Share on other sites

  • 0
15 minutes ago, WopsS said:

if (GiftTakenDate[playerid] > gettime()) // Verifici daca au trecut 24 de ore sau nu in momentul in care se executa comanda.
{
	return SendClientMessage(playerid, -1, "Ai luat deja cadoul, revin-o mai tarziu.");
}

// Codul tau daca trece de verificarea de mai sus.

GiftTakenDate[playerid] = gettime() + 86400; // Atribui valoarea variabilei adunand 86400 (86400 = 24 de ore in secunde) la timpul curent.

 

 0

astea le pun la comanda /getgift ?

  • Upvote 1
Link to comment
Share on other sites

  • 0

CMD:getgift(playerid)
{
    if(!IsPlayerConnected(playerid))
        return SendClientMessage(playerid, -1, "You must be logged in to do this.");

    GetObjectPos(giftboxobject, giftPos[0], giftPos[1], giftPos[2]);
    
    if(IsPlayerInRangeOfPoint(playerid, 5.0, giftPos[0], giftPos[1], giftPos[2]) && giftboxcreated == 1)
    {
    RandomGift(playerid);
    }
    if (GiftTakenTime[playerid] > gettime())
    {
    return SendClientMessage(playerid, -1, "Ai luat deja cadoul, revin-o mai tarziu.");
    }
    GiftTakenTime[playerid] = gettime() + 86400;
    return 1;
}

  • Upvote 1
Link to comment
Share on other sites

  • 0

Verificarea

if (GiftTakenDate[playerid] > gettime()) // Verifici daca au trecut 24 de ore sau nu in momentul in care se executa comanda.
{
	return SendClientMessage(playerid, -1, "Ai luat deja cadoul, revin-o mai tarziu.");
}

  o pui inainte de tot ce executi tu in functia ta. Adica inainte de

if(!IsPlayerConnected(playerid))
        return SendClientMessage(playerid, -1, "You must be logged in to do this."); 
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.