Need help finishing /afk and /back commands
#1

So i'v the /afk works fine, but how can i make it so when a player types /back it respawns them back into a random spawn point and they can keep playings

Random spawn points cords.
Код:
{-1931.8972, 353.8917, 33.3985, 90.9442},
    {-1952.7057, 368.0967, 35.9688, 91.8842},
    {-1952.0062, 400.9029,35.9688, 125.4112}
Pastebin - http://pawn.pastebin.com/AViymiK9
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/afk", true))
    {
    SetupPlayerForClassSelection(playerid);
    TogglePlayerControllable(playerid, 0);
	return 1;
    }
    if(!strcmp(cmdtext, "/back", true))
    {
    TogglePlayerControllable(playerid, 1);
    new rand = random(sizeof(RandomSpawn));
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
	return 1;
    }
    return 0;
    }
if anybody could help me it would i would be very thankful
Reply
#2

Try this:

Код:
new bool:isafk[MAX_PLAYERS];//top of script

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext,"/afk",true))
    {
        new name[MAX_PLAYER_NAME];
        if(isafk[playerid] == false)
        {
	        isafk[playerid] = true;
			GetPlayerHealth(playerid, pHealth);
	  		SetPlayerHealth(playerid, 9999);
	        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
	        format(string, sizeof(string), "%s Is Now AFK!",name);
	        printf(string);
	        SendClientMessage(playerid, 0x0, "Type /back To Stop Being AFK.");
	        SendClientMessageToAll(0x0, string);
	        TogglePlayerControllable(playerid,0);
        }
        else
		{
			SendClientMessage(playerid, 0x0, "Your Already AFK!");
        }
        return 1;
    }
    if(!strcmp(cmdtext,"/back",true))
    {
        new name[MAX_PLAYER_NAME];
        if(isafk[playerid] == true)
        {
	        isafk[playerid] = false;
	        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
	        format(string, sizeof(string), "%s Is No Longer AFK.",name);
	        SendClientMessageToAll(0x0, string);
	        SetPlayerHealth(playerid, pHealth);
	       	printf(string);
			TogglePlayerControllable(playerid,1);
		}
		else
		{
  			SendClientMessage(playerid, 0x0, "Your Not AFK!");
        }
        return 1;
    }
Reply
#3

Quote:
Originally Posted by <Weponz>
Посмотреть сообщение
Try this:

Код:
new bool:isafk[MAX_PLAYERS];//top of script

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext,"/afk",true))
    {
        new name[MAX_PLAYER_NAME];
        if(isafk[playerid] == false)
        {
	        isafk[playerid] = true;
			GetPlayerHealth(playerid, pHealth);
	  		SetPlayerHealth(playerid, 9999);
	        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
	        format(string, sizeof(string), "%s Is Now AFK!",name);
	        printf(string);
	        SendClientMessage(playerid, 0x0, "Type /back To Stop Being AFK.");
	        SendClientMessageToAll(0x0, string);
	        TogglePlayerControllable(playerid,0);
        }
        else
		{
			SendClientMessage(playerid, 0x0, "Your Already AFK!");
        }
        return 1;
    }
    if(!strcmp(cmdtext,"/back",true))
    {
        new name[MAX_PLAYER_NAME];
        if(isafk[playerid] == true)
        {
	        isafk[playerid] = false;
	        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
	        format(string, sizeof(string), "%s Is No Longer AFK.",name);
	        SendClientMessageToAll(0x0, string);
	        SetPlayerHealth(playerid, pHealth);
	       	printf(string);
			TogglePlayerControllable(playerid,1);
		}
		else
		{
  			SendClientMessage(playerid, 0x0, "Your Not AFK!");
        }
        return 1;
    }
nice, but i got 5 errors :/

Код:
C:\Documents and Settings\Hayden Bruin\Desktop\Haydz\Courtroom DM\gamemodes\CourtroomDM.pwn(62) : error 017: undefined symbol "pHealth"
C:\Documents and Settings\Hayden Bruin\Desktop\Haydz\Courtroom DM\gamemodes\CourtroomDM.pwn(65) : error 017: undefined symbol "string"
C:\Documents and Settings\Hayden Bruin\Desktop\Haydz\Courtroom DM\gamemodes\CourtroomDM.pwn(65) : error 017: undefined symbol "string"
C:\Documents and Settings\Hayden Bruin\Desktop\Haydz\Courtroom DM\gamemodes\CourtroomDM.pwn(65) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Hayden Bruin\Desktop\Haydz\Courtroom DM\gamemodes\CourtroomDM.pwn(65) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#4

Ad this up top of script
Код:
new Float:pHealth;
and this in the commands
Код:
 new string[256];
And comment line 65 so i can see it..
Reply
#5

I believe the string doesn't need to be 256 bytes, it's just a waste of space. It should be about 20 if I counted it right
Reply
#6

http://pawn.pastebin.com/M5AkqfxH this is the script, it's got all the errors at the bottom, thanks for your help.
Reply
#7

Quote:
Originally Posted by Crayon
Посмотреть сообщение
I believe the string doesn't need to be 256 bytes, it's just a waste of space. It should be about 20 if I counted it right
Yah i know when i learnt strings it always had 256 i guess its just habit xD Also CBF Counting and if he adds it to the top of commands he doesnt have to make another after 21 or make it bigger untill 257 xD
Reply
#8

Fixed.

http://pawn.pastebin.com/M140rr0H

EDIT: Wow didnt realised i double posted :O :S Sorry i thought by the time i fixed the script someone would of posted :S
Reply
#9

Quote:
Originally Posted by <Weponz>
Посмотреть сообщение
Thank you very much.
Reply
#10

Quote:
Originally Posted by Hayden_Bruin
Посмотреть сообщение
Thank you very much.
NP Dude,

All that was wrong was there was 2 the same codes(deleted 1)

Few functions wernt implemented(Not in right section of script)

And it was a bit messed up,

But was no problem,

Feel free to add me on MSN if you'd like minor queries on scripting
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)