Help with sscanf and OnDialogResponse!
#1

Quote:

#define DIALOG_RACE2 6

Quote:

CMD:race2(playerid, params[])
{
if (g_PlayerInRace[playerid] == true)
return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: Ur already on a race!");
if(sscanf(params, "u", target)) return SendClientMessage(playerid, 0xCECECEFF, "[ERROR]: Use: /race2 [ID]");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, 0xCECECEFF, "[ERROR]: Offline Player!");
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
new String[128];
format(String, sizeof(String), "{00C2EC}You've been challanged by{1B95E0}%s{00C2EC} to the Wood's Race!", pname);
ShowPlayerDialog(target, DIALOG_RACE2, DIALOG_STYLE_MSGBOX, "Race", String, "Accept", "Decline");
return 1;
}

Quote:

if(dialogid == DIALOG_RACE2)
{
if(response)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
format(string, sizeof(string), "[Tele]: %s started a Race on the Woods! {FF8040}(/Race2)", pname);
SendClientMessageToAll(0xFFFF00AA, string);
SetPlayerPos(playerid,-1563,-1919,87);
SetPlayerInterior(playerid, 0);
SetPlayerPos(target,-1563,-1914,86);
SetPlayerInterior(target, 0);
sandking[playerid]=CreateVehicle(495,-1563,-1919,87,190,random(20), random(20),-1);
PutPlayerInVehicle(playerid,sandking[playerid], 0);
sandking[playerid]=CreateVehicle(495,-1563,-1914,86,190,random(20), random(20),-1);
PutPlayerInVehicle(target,sandking[playerid], 0);
TogglePlayerControllable(playerid, 0);
TogglePlayerControllable(target, 0);
SetTimerEx("start", 3000, false, "i", playerid);
SetTimerEx("start", 3000, false, "i", target);
GameTextForPlayer(playerid, "~r~Get Ready...", 3000, 4);
GameTextForPlayer(target, "~r~Get Ready...", 3000, 4);
g_ProgresInRace[playerid] = 15;
g_PlayerInRace[playerid] = true;
g_ProgresInRace[target] = 15;
g_PlayerInRace[target] = true;
SetPlayerRaceCheckpoint(playerid, 1, checkpoints[15][0], checkpoints[15][1], checkpoints[15][2], checkpoints[16][0], checkpoints[16][1], checkpoints[16][2], 12.5);
SetPlayerRaceCheckpoint(target, 1, checkpoints[15][0], checkpoints[15][1], checkpoints[15][2], checkpoints[16][0], checkpoints[16][1], checkpoints[16][2], 12.5);
TextDrawShowForPlayer(playerid, reapir);
TextDrawShowForPlayer(playerid, nitro);
TextDrawShowForPlayer(playerid, flip);
if(g_Ramp[playerid] == 1)
{
TextDrawShowForPlayer(playerid, ramp);
}
}
if(!response)
{

}
return 1;
}

What should happen:
The X player types /race2 [ID], the Y player recieves a dialog asking if he wants to race or not. Until that part everything is OK, then if the Y player accepts, both of them are going to be teleported and start the race inside of a Sandking car with the checkpoints bein activated.

What happens:
Only the Y player is teleported with the car/checkpoints and all that stuff. Nothing happens to the X player.

Hope you can understand and give me a hand omfg! O_o
Reply
#2

You need add array for ids for example
under define
pawn Код:
new RacePlayer[MAX_PLAYERS] = {INVALID_PLAYER_ID, ...};
then in cmd race2
pawn Код:
RacePlayer[target] = playerid;
//dialog here
and if player Y accept

pawn Код:
new target = RacePlayer[playerid];
if(IsPlayerConnected(target) && !g_PlayerInRace[target]) // if player is still connected and is not in race
{
    // your code
}
if not, set
pawn Код:
RacePlayer[playerid] = INVALID_PLAYER_ID;
Reply
#3

EDIT: I read your post wrong, but... I don't know how to put that into my code.
Reply
#4

Well my idea was to if a Player wants to race another, he types like "/Race [ID of the player]", then a dialog asking if he accepts or not is going to appear for the challanged player. Until that part eveything works fine.
Then, if the player that has been challanged accepts, both of them should be teleported to the race place, inside of a car with a countdown and stuff running, but only the player that recieves the challange is being teleported...

Hope you can understand now!
Reply
#5

Post full .pwn to PM, So i can explain it a little bit.


// I Need the PWN to see how did you structure it, also did you tab the commands?
Reply
#6

pawn Код:
new RacePlayer[MAX_PLAYERS] = {INVALID_PLAYER_ID, ...};

CMD:race2(playerid, params[])
{
    if(g_PlayerInRace[playerid] == true) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: Ur already on a race!");
    if(sscanf(params, "u", target)) return SendClientMessage(playerid, 0xCECECEFF, "[ERROR]: Use: /race2 [ID]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, 0xCECECEFF, "[ERROR]: Offline Player!");
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    new String[128];
    RacePlayer[target] = playerid;
    format(String, sizeof(String), "{00C2EC}You've been challanged by{1B95E0}%s{00C2EC} to the Wood's Race!", pname);
    ShowPlayerDialog(target, DIALOG_RACE2, DIALOG_STYLE_MSGBOX, "Race", String, "Accept", "Decline");
    return 1;
}

if(dialogid == DIALOG_RACE2)
{
    if(!response) RacePlayer[playerid] = INVALID_PLAYER_ID;
    else
    {
        new target = RacePlayer[playerid];
        if(IsPlayerConnected(target) && !g_PlayerInRace[target]) // if player is still connected and is not in race
        {
            new pname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
            format(string, sizeof(string), "[Tele]: %s started a Race on the Woods! {FF8040}(/Race2)", pname);
            SendClientMessageToAll(0xFFFF00AA, string);
            SetPlayerPos(playerid,-1563,-1919,87);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(target,-1563,-1914,86);
            SetPlayerInterior(target, 0);
            sandking[playerid] = CreateVehicle(495,-1563,-1919,87,190,random(20), random(20),-1);
            PutPlayerInVehicle(playerid,sandking[playerid], 0);
            sandking[target] = CreateVehicle(495,-1563,-1914,86,190,random(20), random(20),-1);
            PutPlayerInVehicle(target,sandking[target], 0);
            TogglePlayerControllable(playerid, 0);
            TogglePlayerControllable(target, 0);
            SetTimerEx("start", 3000, false, "i", playerid);
            SetTimerEx("start", 3000, false, "i", target);
            GameTextForPlayer(playerid, "~r~Get Ready...", 3000, 4);
            GameTextForPlayer(target, "~r~Get Ready...", 3000, 4);
            g_ProgresInRace[playerid] = 15;
            g_PlayerInRace[playerid] = true;
            g_ProgresInRace[target] = 15;
            g_PlayerInRace[target] = true;
            SetPlayerRaceCheckpoint(playerid, 1, checkpoints[15][0], checkpoints[15][1], checkpoints[15][2], checkpoints[16][0], checkpoints[16][1], checkpoints[16][2], 12.5);
            SetPlayerRaceCheckpoint(target, 1, checkpoints[15][0], checkpoints[15][1], checkpoints[15][2], checkpoints[16][0], checkpoints[16][1], checkpoints[16][2], 12.5);
            TextDrawShowForPlayer(playerid, reapir);
            TextDrawShowForPlayer(playerid, nitro);
            TextDrawShowForPlayer(playerid, flip);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)