Help with this
#1

Hi well look I want to do a function that if you die inside a mini game you respawn inside it again and with the weapons of the mini game and all its staff.
Reply
#2

SetSpawnInfo and SpawnPlayer?
Reply
#3

You can use playerinfo[playerid][pDm] . set it to 1 when he joins and to 0 when he quits and then you can create cmds with this pInfo
Reply
#4

Quote:
Originally Posted by PepsiCola23
Посмотреть сообщение
You can use playerinfo[playerid][pDm] . set it to 1 when he joins and to 0 when he quits and then you can create cmds with this pInfo
I don't see the point in doing that. You could simply use variables and per-player variables.

Here's a script that you can use a reference:
pawn Код:
// [ DEVELOPMENT GAMEMODE ]

// INCLUDES:

#include <a_samp>
#include <zcmd>
#include <sscanf2>

// DEFINES:

// GENERAL:

#define MAX_MINIGAMES 2

// MINIGAMES:

#define MINIGAME_DM 0
#define MINIGAME_DERBY 1

// VARIABLES:

new bool:sMinigame[MAX_PLAYERS][MAX_MINIGAMES];

// MAIN:

main()
{
    print("Development Mode: minigame_respawn.amx");
}

// CALLBACKS:

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(IsPlayerInAnyMinigame(playerid))
    {
        new minigame = GetPlayerMinigameID(playerid);
        GivePlayerMinigameWeapons(playerid, minigame);
        SpawnPlayerInMinigame(playerid, minigame);
    }
    return 1;
}

// COMMANDS:

CMD:join(playerid, params[])
{
    new minigame;
    if(sscanf(params, "i", minigame)) return SendClientMessage(playerid, -1, "Usage: /join (minigame id).");
    if(minigame < 0 || minigame > MAX_MINIGAMES) return SendClientMessage(playerid, -1, "Invalid minigame, valid minigames: 0, 1.");

    sMinigame[playerid][minigame] = true;
    GivePlayerMinigameWeapons(playerid, minigame);
    SpawnPlayerInMinigame(playerid, minigame);
    return 1;
}

CMD:leave(playerid, params[])
{
    if(!IsPlayerInAnyMinigame(playerid)) return SendClientMessage(playerid, -1, "You are not in a minigame, you cannot use this command.");

    new minigame = GetPlayerMinigameID(playerid);
    sMinigame[playerid][minigame] = false;
    SpawnPlayer(playerid);
    return 1;
}

// FUNCTIONS:

stock IsPlayerInMinigame(playerid, minigame)
{
    if(sMinigame[playerid][minigame]) return true;
    return false;
}

stock IsPlayerInAnyMinigame(playerid)
{
    new bool:found = false;
    for(new i = 0; i < MAX_MINIGAMES; i ++)
    {
        if(sMinigame[playerid][i])
        {
            found = true;
            break;
        }
    }

    if(found) return true;
    return false;
}

stock GetPlayerMinigameID(playerid)
{
    new id = -1;
    for(new i = 0; i < MAX_MINIGAMES; i ++)
    {
        if(sMinigame[playerid][i])
        {
            id = i;
            break;
        }
    }
    return id;
}

stock SpawnPlayerInMinigame(playerid, minigame)
{
    switch(minigame)
    {
        case MINIGAME_DM:
        {
            SetPlayerPos(playerid, 0.0, 0.0, 0.0);
            SetPlayerFacingAngle(playerid, 0.0);
            SetCameraBehindPlayer(playerid);
        }
        case MINIGAME_DERBY:
        {
            SetPlayerPos(playerid, 0.0, 0.0, 0.0);
            SetPlayerFacingAngle(playerid, 0.0);
            SetCameraBehindPlayer(playerid);
        }
    }
}

stock GivePlayerMinigameWeapons(playerid, minigame)
{
    switch(minigame)
    {
        case MINIGAME_DM:
        {
            GivePlayerWeapon(playerid, 26, 500);
            GivePlayerWeapon(playerid, 31, 500);
        }
    }
}
Reply
#5

Quote:
Originally Posted by PepsiCola23
Посмотреть сообщение
You can use playerinfo[playerid][pDm] . set it to 1 when he joins and to 0 when he quits and then you can create cmds with this pInfo
1. SickAttack's little example is good.
2. @PepsiCola23; STOP USING 1 AND 0 IN PLACE OF TRUE AND FALSE. USE BOOLEANS!
Reply
#6

Thank you very much to all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)