Change player class on cmd
#1

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

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

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.
Reply
#4

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

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)