OnPlayerRequestClass
#1

Hello,

I'm working on a gamemode, but there are some problems.
This is one of them, i hope you can help me fixing this .

When a player is logged in he has to choose a team, and if we clicks the spawn it works fine.
But I want to send a message to all players to tell them he joined a class.
My code:
Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 180.892608, 1830.717895, 23.242187);
    SetPlayerFacingAngle(playerid, 255.810241);
    SetPlayerCameraLookAt(playerid, 180.892608, 1830.717895, 23.242187);
    SetPlayerCameraPos(playerid, 180.892608 + (5 * floatsin(-255.810241, degrees)), 1830.717895 + (5 * floatcos(-255.810241, degrees)), 23.242187);
	switch(classid)
    {
         case 0:
         {
              SetPlayerTeam(playerid, TEAMRed);
              SendClientMessageToAll(COLOR_RED, "I will write a message here");
              GameTextForPlayer(playerid, "~r~Red", 1000, 3);
         }
         case 1:
         {
              SetPlayerTeam(playerid, TEAMBlue);
              SendClientMessageToAll(COLOR_BLUE, "I will write a message here");
              GameTextForPlayer(playerid, "~b~Blue", 1000, 3);
         }
     }
	return 1;
}
Butt it gives messages while switching to see with kind of classes there are..

Can someone help?
Thankyou!
Reply
#2

Dude, Put that message under:

Код:
OnPlayerSpawn;
Reply
#3

You can get that performed under OnPlayerSpawn. Use arrays to determine what class the player has chosen.
pawn Код:
new
    p_Class[MAX_PLAYERS];
public OnPlayerRequestClass(playerid, classid)
{
    p_Class[playerid] = classid; //Sets the classid of the player.
    SetPlayerPos(playerid, 180.892608, 1830.717895, 23.242187);
    SetPlayerFacingAngle(playerid, 255.810241);
    SetPlayerCameraLookAt(playerid, 180.892608, 1830.717895, 23.242187);
    SetPlayerCameraPos(playerid, 180.892608 + (5 * floatsin(-255.810241, degrees)), 1830.717895 + (5 * floatcos(-255.810241, degrees)), 23.242187);
    switch(classid)
    {
         case 0:
         {
              SetPlayerTeam(playerid, TEAMRed);
              SendClientMessageToAll(COLOR_RED, "I will write a message here");
              GameTextForPlayer(playerid, "~r~Red", 1000, 3);
         }
         case 1:
         {
              SetPlayerTeam(playerid, TEAMBlue);
              SendClientMessageToAll(COLOR_BLUE, "I will write a message here");
              GameTextForPlayer(playerid, "~b~Blue", 1000, 3);
         }
     }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    switch(p_Class[playerid]) {
        case 0 : SendClientMessage(playerid, -1, "Hello, welcome to Team Red!"); //You can replace these messages, it's just an example.
        case 1 : SendClientMessage(playerid, -1, "Hello, welcome to Team Blue!");
    }
    //Rest codes.
    return 1;
}
Reply
#4

Quote:
Originally Posted by Lordz™
Посмотреть сообщение
You can get that performed under OnPlayerSpawn. Use arrays to determine what class the player has chosen.
pawn Код:
new
    p_Class[MAX_PLAYERS];
public OnPlayerRequestClass(playerid, classid)
{
    p_Class[playerid] = classid; //Sets the classid of the player.
    SetPlayerPos(playerid, 180.892608, 1830.717895, 23.242187);
    SetPlayerFacingAngle(playerid, 255.810241);
    SetPlayerCameraLookAt(playerid, 180.892608, 1830.717895, 23.242187);
    SetPlayerCameraPos(playerid, 180.892608 + (5 * floatsin(-255.810241, degrees)), 1830.717895 + (5 * floatcos(-255.810241, degrees)), 23.242187);
    switch(classid)
    {
         case 0:
         {
              SetPlayerTeam(playerid, TEAMRed);
              SendClientMessageToAll(COLOR_RED, "I will write a message here");
              GameTextForPlayer(playerid, "~r~Red", 1000, 3);
         }
         case 1:
         {
              SetPlayerTeam(playerid, TEAMBlue);
              SendClientMessageToAll(COLOR_BLUE, "I will write a message here");
              GameTextForPlayer(playerid, "~b~Blue", 1000, 3);
         }
     }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    switch(p_Class[playerid]) {
        case 0 : SendClientMessage(playerid, -1, "Hello, welcome to Team Red!"); //You can replace these messages, it's just an example.
        case 1 : SendClientMessage(playerid, -1, "Hello, welcome to Team Blue!");
    }
    //Rest codes.
    return 1;
}
Thank you sooooooo much!
SOLVED
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)