Spawn player to All Saints Hospital when killed
#1

Please teach me how to spawn the player to All Saints Hospital when killed. Any help will be thanked
Reply
#2

https://sampwiki.blast.hk/wiki/SetPlayerPos
Reply
#3

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
Код:
new
	bool:pKilled[MAX_PLAYERS char] = {false};

public OnPlayerDeath(playerid, killerid, reason)
{
	if (killerid != INVALID_PLAYER_ID) // If killed
		pKilled{playerid} = true; // Set var to true
}

public OnPlayerSpawn(playerid)
{
	if (pKilled{playerid}) { // Killed?
		SetPlayerPos(playerid, X, Y, Z); // Replace the X Y Z coords with the ones near the hospital
		pKilled{playerid} = false;
	}
}
I got errors

Код:
C:\Users\4neals\Desktop\Samp\Main\gamemodes\FreeRoam.pwn(99) : error 017: undefined symbol "pKilled"
C:\Users\4neals\Desktop\Samp\Main\gamemodes\FreeRoam.pwn(99) : warning 215: expression has no effect
C:\Users\4neals\Desktop\Samp\Main\gamemodes\FreeRoam.pwn(99) : error 001: expected token: ";", but found "}"
C:\Users\4neals\Desktop\Samp\Main\gamemodes\FreeRoam.pwn(105) : error 010: invalid function or declaration
C:\Users\4neals\Desktop\Samp\Main\gamemodes\FreeRoam.pwn(111) : error 017: undefined symbol "pKilled"
C:\Users\4neals\Desktop\Samp\Main\gamemodes\FreeRoam.pwn(111) : warning 215: expression has no effect
C:\Users\4neals\Desktop\Samp\Main\gamemodes\FreeRoam.pwn(111) : error 001: expected token: ";", but found "}"
C:\Users\4neals\Desktop\Samp\Main\gamemodes\FreeRoam.pwn(116) : error 010: invalid function or declaration
C:\Users\4neals\Desktop\Samp\Main\gamemodes\FreeRoam.pwn(198) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
My full code
Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_SEAGREEN 0x20B2AAAA
#define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xFFC0CBAA // - Light light pink
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
#define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREY 0xAFAFAFAA
	stock AddClasses()
	{
    new a = 0;
    while(a <= 299)
    {
    
    new
	bool:pKilled[MAX_PLAYERS char] = {false};

main()
{
	print("\n----------------------------------");
	print(" Future FreeRoam Server - NealP");
	print("----------------------------------\n");
}

new Text:textid = TextDrawCreate(100.0, 100.0, "Hello! Welcome to the Future FreeRoam. Please enjoy the server.");
TextDrawShowForAll(textid);

public OnGameModeInit()
{
        AddPlayerClass(a, 2485.6213,-1665.0665,15, -1, 0, 0, 0, 0, 0, 0);
        a = a + 1;
    }
}
	SetGameModeText("Welcome to the Future FreeRoam");
	ManualVehicleEngineAndLights();
	DisableInteriorEnterExits()
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
    new string[64], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string,sizeof string,"%s has joined the server. Welcome!",pName);
    SendClientMessageToAll(0xFFFFFFAA,string);

	GameTextForPlayer(playerid,"~w~The Future Freeroam",3000,4);
	SendClientMessage(playerid,COLOR_WHITE, "Welcome to The {FF0000}F{FFFFFF}uture {00FF00}F{FFFFFF}ree{0080FF}R{FFFFFF}oam");
	return 1;
}

public OnPlayerSpawn(playerid)
{
	if (pKilled{playerid}) { // Killed?
	SetPlayerPos(playerid, X, Y, Z); // Replace the X Y Z coords with the ones near the hospital
	pKilled{playerid} = false;
	SetPlayerColor(playerid,COLOR_WHITE);
	GivePlayerMoney(playerid, 1000);
	GivePlayerWeapon(playerid, WEAPON_COLT45,100);
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	if (killerid != INVALID_PLAYER_ID) // If killed
	pKilled{playerid} = true; // Set var to true
	SetPlayerPos(playerid, 1172.9683,-1323.3954,15.3982);
	SendClientMessage(playerid,COLOR_YELLOW,"You were treated by medical doctors in All Saints Hospital. Please be careful next time.");
	SendClientMessage(playerid,COLOR_YELLOW,"You were deducted by $200 for your medical bill. Have a safe day!");
	GivePlayerMoney(playerid,-200);
   	return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/kill", cmdtext, true, 10) == 0)
	{
	if (IsPlayerAdmin(playerid))
	SendClientMessage(playerid,COLOR_RED,"You commited suicide.");
	SetPlayerHealth(playerid,0);
	return 1;
	}
	if (strcmp("/adminhelp", cmdtext, true, 10) == 0)
	{
	if (IsPlayerAdmin(playerid))
	SendClientMessage(playerid,COLOR_YELLOW,"/adminstarter /skinchange /specplayer /specvehicle /specoff /chouse /cbusiness /cpolice /cbank /view  /return /vspawner");
	return 1;
 	}
	if (strcmp("/help", cmdtext, true, 10) == 0)
	{
	SendClientMessage(playerid,COLOR_YELLOW,"/animlist /engine /lock /me /do /b /megaphone /low /ooc /toogleooc /whisper");
	return 1;
 	}
	if (strcmp("/adminstarter", cmdtext, true, 10) == 0)
	{
	if (IsPlayerAdmin(playerid))
	SetPlayerHealth(playerid,100);
	SetPlayerArmour(playerid,100);
	GivePlayerWeapon(playerid,WEAPON_MINIGUN,999999);
	GivePlayerWeapon(playerid,WEAPON_M4,999999);
	GivePlayerWeapon(playerid,WEAPON_DEAGLE,999999);
	SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USEJETPACK);
	return 1;
	}
	if (strcmp("/engine", cmdtext, true, 10) == 0)//your command.
    {
        new vehicleid = GetPlayerVehicleID(playerid);//defining vehicleid is = to GetPlayerVehicleID.
        new engine, lights, alarm, doors, bonnet, boot, objective;//these are the defines of the thing used in the command.
        if(IsPlayerInAnyVehicle(playerid))//This will check that if a player is in the vehicle or not.
            {
                if(GetPlayerVehicleSeat(playerid) == 0) //Now this will check that if a player is on the driving seat or not.
                {
                    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);//will check that what is the state of the engine.
                    if(engine == 1)//will check that if the wngine in on or not.
                    {
                        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);//this will check that what is the state of engine.That is is on or off.We can use it for multiple things like doors,alarms etc.But In this case I am using this for the engine only.
                        SetVehicleParamsEx(vehicleid,false,lights,alarm,doors,bonnet,boot,objective);//when we change the engine and replace it with false,this will turn the vehicle engine off.Same if we make if true,this will make the engine on.
                        GameTextForPlayer(playerid,"Vehicle Engine Stopped!",2000,6);//for a text to appar on the screen for only 2 seconds.
                        return 1;
                    }
                    else
                    SetVehicleParamsEx(vehicleid,true,lights,alarm,doors,bonnet,boot,objective);//if vehicle engine is false it will change it to true.
                    GameTextForPlayer(playerid,"Vehicle Engine Started!",2000,6);//for a text to appar on the screen for only 2 seconds.
                }
                else SendClientMessage(playerid,-1,"Error: You are not at the driving seat!");//this is an error message,that if a player is not on the driving seat,this error message would appear.
                return 1;
            }
            else
            SendClientMessage(playerid,-1,"Error: You are not in a vehicle!");//this is the error message,that if a player is not in the car,the error message would apper.
    }
    if (strcmp("/lock", cmdtext, true, 10) == 0)//your command.
    {
        new engine, lights, alarm, doors, bonnet, boot, objective;
        new vehicleid = GetPlayerVehicleID(playerid);//defining vehicleid is = to GetPlayerVehicleID.
        if(IsPlayerInAnyVehicle(playerid))//Thsi will check that is a player In a vehcile or not.
            {
                GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);//will check that what is the state of the vehicle lock.
                if(doors == 1)//will check if the doors are already loocked it not.
                {
                    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(vehicleid,engine,lights,alarm,false,bonnet,boot,objective);//same as the engine one.
                    GameTextForPlayer(playerid,"Vehicle Unlocked!",2000,6);//for a text to appar on the screen for only 2 seconds.
              		return 1;
                }
                else
                SetVehicleParamsEx(vehicleid,engine,lights,alarm,true,bonnet,boot,objective);
                GameTextForPlayer(playerid,"Vehicle Locked!",2000,6);//for a text to appar on the screen for only 2 seconds.
            }
            else
            SendClientMessage(playerid,-1,"Error: You are not in a vehicle!");//the error message.
    }
        return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new string[128];
    format(string, sizeof(string), "You are entering vehicle %i", vehicleid);
    SendClientMessage(playerid, 0xFFFFFFFF, string);
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    new string[35];
    format(string, sizeof(string), "INFO: You are exiting vehicle %i", vehicleid);
    SendClientMessage(playerid, 0xFFFFFFFF, string);
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	DisablePlayerCheckpoint(playerid);
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	return 0;
}

public OnPlayerDisconnect(playerid, reason)
{
    new
        szString[64],
        playerName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);

    new szDisconnectReason[3][] =
    {
        "Timeout/Crash",
        "Quit",
        "Kick/Ban"
    };

    format(szString, sizeof szString, "%s left the server (%s).", playerName, szDisconnectReason[reason]);

    SendClientMessageToAll(0xC4C4C4FF, szString);
    return 1;
}
Reply
#4

Or you can SetPlayerPos on the OnPlayerSpawn callback so everytime you login or die you will spawn there obviously you need to use /save and get the coords from your documents folder.
To fix those issues though make sure you add the variable pKilled.
Reply
#5

Give me ur hospital code,put this under ,Public OnplayerSpawn. SetPlayerPos(playerid, x , y x");
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)