SA-MP Forums Archive
OnPlayerRequestClass - 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: OnPlayerRequestClass (/showthread.php?tid=495258)



OnPlayerRequestClass - trukker1998 - 16.02.2014

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!


Re: OnPlayerRequestClass - Bingo - 16.02.2014

Dude, Put that message under:

Код:
OnPlayerSpawn;



Re: OnPlayerRequestClass - Lordzy - 16.02.2014

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



Re: OnPlayerRequestClass - trukker1998 - 18.02.2014

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