SA-MP Forums Archive
Change player class on cmd - 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: Change player class on cmd (/showthread.php?tid=446002)



Change player class on cmd - exclide1 - 24.06.2013

It should instantly send player to class selection screen and spawn. Is it possible?


Respuesta: Change player class on cmd - JustBored - 24.06.2013

There is a function called https://sampwiki.blast.hk/wiki/ForceClassSelection


Re: Respuesta: Change player class on cmd - exclide1 - 24.06.2013

Quote:
Originally Posted by JustBored
Посмотреть сообщение
Thanks. Can you tip me up with a few more functions, responsible for switching classes and spawning player? "SpawnPlayer" doesn't work.


Re: Change player class on cmd - _Khaled_ - 24.06.2013

pawn Код:
if (strcmp(cmdtext, "/spawn", true) == 0)
{
    SpawnPlayer(playerid);
    return 1;
}
https://sampwiki.blast.hk/wiki/SpawnPlayer


Re: Change player class on cmd - exclide1 - 24.06.2013

Alright, I have this now:
pawn Код:
CMD:teamchange(playerid, params[])
{
    ForceClassSelection(playerid);
    TogglePlayerSpectating(playerid, true);
    TogglePlayerSpectating(playerid, false);
    SetSpawnInfo(playerid, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    SpawnPlayer(playerid);
    return 1;
}
It sends you instantly to class selection screen and spawns you (doesn't spawn without "SetSpawnInfo"). But how do I make it actually switch to the class ID I want?

EDIT: I tried to do it with Y_Classes:
pawn Код:
CMD:teamc(playerid, params[])
{
    Class_ReturnToSelection(playerid);
    Class_Goto(playerid, 7);
    SpawnPlayer(playerid);
    return 1;
}
It should go to the class ID "7" and spawn me, but it spawns my current class. Any ideas? Should I probably make a timer for this?

EDIT2: Alright, I did this. Thanks for the help!
pawn Код:
CMD:teamc(playerid, params[])
{
    Class_ReturnToSelection(playerid);
    Class_Goto(playerid, 7);
    SetTimerEx("spawnnow",100,0,"i",playerid);
    return 1;
}


forward spawnnow(playerid);
public spawnnow(playerid)
{
    SpawnPlayer(playerid);
    return 1;
}