invite command
#1

Hi I have VIP Room. And this is basically for vip members. But I also want to invite players who are not vip players in the room. Can you please make demo script for this? thanks alot!
Reply
#2

Quick example

pawn Код:
new
    bool:PlayerInvitedPlayer [ MAX_PLAYERS ]
;


CMD:invite(playerid, params[])
{
    new
        targetid
    ;

    if(sscanf(params, "u", targetid))
        return SendClientMessage(playerid, -1, "Syntax: /invite [Player Name/ID]")

    SetPlayerCheckpoint( targetid, PositionX, PositionY, PositionZ, CheckpointSize ) //VIP Entrance Position
    PlayerInvitedPlayer[playerid] = true;
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    if(PlayerInvitedPlayer[playerid] == true)
    {
        SetPlayerPos(playerid, PositionX, PositionY, PositionZ)//Inside VIP Position
        SetPlayerInterior(playerid, InteriorID)//VIP Interior ID
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
Quick example

pawn Код:
new
    bool:PlayerInvitedPlayer [ MAX_PLAYERS ]
;


CMD:invite(playerid, params[])
{
    new
        targetid
    ;

    if(sscanf(params, "u", targetid))
        return SendClientMessage(playerid, -1, "Syntax: /invite [Player Name/ID]")

    SetPlayerCheckpoint( targetid, PositionX, PositionY, PositionZ, CheckpointSize ) //VIP Entrance Position
    PlayerInvitedPlayer[playerid] = true;
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    if(PlayerInvitedPlayer[playerid] == true)
    {
        SetPlayerPos(playerid, PositionX, PositionY, PositionZ)//Inside VIP Position
        SetPlayerInterior(playerid, InteriorID)//VIP Interior ID
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
Wow thanks alot for responding.. Anyway I got this warnings..

Код:
 error 017: undefined symbol "PositionX"
error 017: undefined symbol "PositionX"
error 017: undefined symbol "InteriorID"
this line
Код:
SetPlayerPos(playerid, PositionX, PositionY, PositionZ)
Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(PlayerInvitedPlayer[playerid] == true)
    {
        SetPlayerPos(playerid, PositionX, PositionY, PositionZ)//Inside VIP Position
        SetPlayerInterior(playerid, InteriorID)//VIP Interior ID
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
this is the coordinates I want to put
Код:
-710.6376,1851.7188,8.7459
Actually its not inside a interior its just an customized outdoor room and the virtual world was 20.
Reply
#4

Quote:
Originally Posted by kbalor
Посмотреть сообщение
Wow thanks alot for responding.. Anyway I got this warnings..

Код:
 error 017: undefined symbol "PositionX"
error 017: undefined symbol "PositionX"
error 017: undefined symbol "InteriorID"
this line
Код:
SetPlayerPos(playerid, PositionX, PositionY, PositionZ)
Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(PlayerInvitedPlayer[playerid] == true)
    {
        SetPlayerPos(playerid, PositionX, PositionY, PositionZ)//Inside VIP Position
        SetPlayerInterior(playerid, InteriorID)//VIP Interior ID
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
this is the coordinates I want to put
Код:
-710.6376,1851.7188,8.7459
Actually its not inside a interior its just an customized outdoor room and the virtual world was 20.

Try changing them your own, you need to learn something, you are high roller.
Reply
#5

Quote:
Originally Posted by pds2k12
Посмотреть сообщение

Try changing them your own, you need to learn something, you are high roller.
I got it working now...

Код:
CMD:invite(playerid, params[])
{
    new
        targetid
    ;

    if(sscanf(params, "u",targetid)) return SendClientMessage(playerid, yellow, "Usage: /invite <Part of Nick/Player ID>");
    GameTextForPlayer(playerid,"~y~Welcome to ~n~~b~VIP Room",2000,3);
	SetPlayerPos(playerid, -710.6376,1851.7188,8.7459);
	SetPlayerFacingAngle(playerid, 270);
	SetPlayerInterior(playerid, 0);
	SetPlayerVirtualWorld(playerid, 20);
	SetCameraBehindPlayer(playerid);
	DestroyVehicle(GetPlayerVehicleID(playerid));
    PlayerInvitedPlayer[playerid] = true;
    return 1;
}
Do I still need this then?

Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(PlayerInvitedPlayer[playerid] == true)
    {
        SetPlayerPos(playerid, -710.6376,1851.7188,8.7459);//Inside VIP Position
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by kbalor
Посмотреть сообщение
I got it working now...

Код:
CMD:invite(playerid, params[])
{
    new
        targetid
    ;

    if(sscanf(params, "u",targetid)) return SendClientMessage(playerid, yellow, "Usage: /invite <Part of Nick/Player ID>");
    GameTextForPlayer(playerid,"~y~Welcome to ~n~~b~VIP Room",2000,3);
	SetPlayerPos(playerid, -710.6376,1851.7188,8.7459);
	SetPlayerFacingAngle(playerid, 270);
	SetPlayerInterior(playerid, 0);
	SetPlayerVirtualWorld(playerid, 20);
	SetCameraBehindPlayer(playerid);
	DestroyVehicle(GetPlayerVehicleID(playerid));
    PlayerInvitedPlayer[playerid] = true;
    return 1;
}
Do I still need this then?

Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(PlayerInvitedPlayer[playerid] == true)
    {
        SetPlayerPos(playerid, -710.6376,1851.7188,8.7459);//Inside VIP Position
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
Yes, because if that player enters the checkpoint, it will send you to the location of your X,Y,Z
Reply
#7

Remove the command and the variable I gave you, and change it with this

pawn Код:
new
    bool:_pInvitedSomeone [ MAX_PLAYERS char ]
;

CMD:invite(playerid, params[])
{
    new
        targetid,
        _string [ 90 ],
        _PlayerName [ 24 ]
    ;

    if(sscanf(params, "u",targetid)) return SendClientMessage(playerid, yellow, "Usage: /invite <Part of Nick/Player ID>");

    GetPlayerName(playerid, _PlayerName, sizeof(_PlayerName));

    format(_string, sizeof(_string), "%s has invited you to the VIP, use (/accept) or (/decline)",_PlayerName);

    _pInvitedSomeone{targetid} = true;
    return 1;
}

CMD:accept(playerid, params[])
{
    if( !_pInvitedSomeone { playerid } ) return SendClientMessage(playerid, -1, "Error - No One invited you! ");
    if( _pInvitedSomeone { playerid } ) // means true
    {
        GameTextForPlayer(playerid,"~y~Welcome to ~n~~b~VIP Room",2000,3);
        SetPlayerPos(playerid, -710.6376,1851.7188,8.7459), SetPlayerFacingAngle(playerid, 270),
        SetPlayerInterior(playerid, 0), SetPlayerVirtualWorld(playerid, 20);
        SetCameraBehindPlayer(playerid), DestroyVehicle(GetPlayerVehicleID(playerid));
        _pInvitedSomeone{playerid} = false;
    }
    return 1;
}

CMD:decline(playerid, params[])
{
    if( !_pInvitedSomeone { playerid } ) return SendClientMessage(playerid, -1, "Error - No One invited you! ");
    if( _pInvitedSomeone { playerid } )
    {
        SendClientMessage(playerid, -1, "You have succesfully declined the VIP Invite.");
        _pInvitedSomeone{playerid} = false;
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
Remove the command and the variable I gave you, and change it with this

pawn Код:
new
    bool:_pInvitedSomeone [ MAX_PLAYERS char ]
;

CMD:invite(playerid, params[])
{
    new
        targetid,
        _string [ 90 ],
        _PlayerName [ 24 ]
    ;

    if(sscanf(params, "u",targetid)) return SendClientMessage(playerid, yellow, "Usage: /invite <Part of Nick/Player ID>");

    GetPlayerName(playerid, _PlayerName, sizeof(_PlayerName));

    format(_string, sizeof(_string), "%s has invited you to the VIP, use (/accept) or (/decline)",_PlayerName);

    _pInvitedSomeone{targetid} = true;
    return 1;
}

CMD:accept(playerid, params[])
{
    if( !_pInvitedSomeone { playerid } ) return SendClientMessage(playerid, -1, "Error - No One invited you! ");
    if( _pInvitedSomeone { playerid } ) // means true
    {
        GameTextForPlayer(playerid,"~y~Welcome to ~n~~b~VIP Room",2000,3);
        SetPlayerPos(playerid, -710.6376,1851.7188,8.7459), SetPlayerFacingAngle(playerid, 270),
        SetPlayerInterior(playerid, 0), SetPlayerVirtualWorld(playerid, 20);
        SetCameraBehindPlayer(playerid), DestroyVehicle(GetPlayerVehicleID(playerid));
        _pInvitedSomeone{playerid} = false;
    }
    return 1;
}

CMD:decline(playerid, params[])
{
    if( !_pInvitedSomeone { playerid } ) return SendClientMessage(playerid, -1, "Error - No One invited you! ");
    if( _pInvitedSomeone { playerid } )
    {
        SendClientMessage(playerid, -1, "You have succesfully declined the VIP Invite.");
        _pInvitedSomeone{playerid} = false;
    }
    return 1;
}
I tried but its not working no warnings at all. But I checked the server log and this is what it shown,

Код:
[19:02:50] [debug] Run time error 4: "Array index out of bounds"
[19:02:50] [debug]  Accessing element at index 65535 past array upper bound 499
[19:02:50] [debug] AMX backtrace:
[19:02:50] [debug] #0 000d1ff0 in public cmd_vinvite (playerid=0, params[]=@0x0115e260 "1") at C:\Users\Kevs\Desktop\A\test\filterscripts\JLadmin.pwn:15488
[19:02:50] [debug] #1 native CallLocalFunction () [00471ef0] from samp-server.exe
[19:02:50] [debug] #2 000206a4 in ?? (... <2 arguments>) at C:\Users\Kevs\Desktop\A\test\pawno\include\zcmd.inc:110
[19:02:50] [debug] #3 00006ae0 in public OnPlayerCommandText (playerid=0, cmdtext[]=@0x0115e234 "/vinvite 1") at C:\Users\Kevs\Desktop\A\test\pawno\include\YSI\y_hooks/impl.inc:918
Reply
#9

Line 15488 from JLadmin.pwn please.

The one you passed in [ ] is INVALID_PLAYER_ID (65535) where the max value it expected was 499 (declared as MAX_PLAYERS).

So check that variable, something like:
pawn Код:
if( variable_name_here != INVALID_PLAYER_ID )
{
    // variable_name_here is the one was set to INVALID_PLAYER_ID and it got passed into the index.
    // now you can insert that variable into array
}
PS: Nothing was wrong with char, the runtime error was caused by command /vinvite. By the way, when char is used, it can only get 0-255. Any value out of bounds will be changed.
Reply
#10

As What Konstantinos said above, you're asigning trying to invite a player who isn't connected.

You could do something like this

pawn Код:
if(!IsPlayerConnected(playerid)) continue;
Or
pawn Код:
if(targetid != INVALID_PLAYER_ID)
{
    // code here
}
@Konstantinos - EDIT: I re-checked the crashdetect error
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)