SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 01/11/2019, 12:56 AM   #1
josh
Little Clucker
 
Join Date: Jul 2019
Posts: 49
Reputation: 0
Default OnPlayerDeath

Hello guys.
I've made two teams, a police team, a criminal team, but I have a problem when someone from the team dies, for example, if a player dies on the criminal team, I want SetPlayerPos for the second team to the lobby, idk how i do that I tried in it did not work can someone help me.
josh is offline   Reply With Quote
Old 01/11/2019, 01:44 AM   #2
Dawkin
Big Clucker
 
Dawkin's Avatar
 
Join Date: Jul 2018
Location: Viet Nam
Posts: 71
Reputation: 14
Default Re: OnPlayerDeath

Post your code here and probably we can help you.
I don't even know how it looks, so how can I help you?
__________________
Discord: Dawkin Nguyen#7590
Dawkin is offline   Reply With Quote
Old 01/11/2019, 09:07 AM   #3
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 363
Reputation: 17
Default Re: OnPlayerDeath

If I understand you correctly (and without any code provided), I can assume you want something like this:

Player dies -> Teleport team back to lobby -> Game end
OR
Player dies -> Teleport player back to lobby -> Game continues until everyone on 1 team is in lobby

Code:
SetPlayerPos(playerid, x, y, z) // edit x y z coords to lobby coordinates
Would do the trick, but I assume you've probably already tried that.

However, it's hard to tell what you've done, how you've done it and how we can help because as ^ said, you haven't provided any code.
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is offline   Reply With Quote
Old 01/11/2019, 09:58 AM   #4
josh
Little Clucker
 
Join Date: Jul 2019
Posts: 49
Reputation: 0
Default Re: OnPlayerDeath

Quote:
Originally Posted by Proxus View Post
If I understand you correctly (and without any code provided), I can assume you want something like this:

Player dies -> Teleport team back to lobby -> Game end
OR
Player dies -> Teleport player back to lobby -> Game continues until everyone on 1 team is in lobby

Code:
SetPlayerPos(playerid, x, y, z) // edit x y z coords to lobby coordinates
Would do the trick, but I assume you've probably already tried that.

However, it's hard to tell what you've done, how you've done it and how we can help because as ^ said, you haven't provided any code.
Quote:
Originally Posted by Dawkin View Post
Post your code here and probably we can help you.
I don't even know how it looks, so how can I help you?
this my code
Code:
//COPS VS CRIMINALS EVENT//
// EVENT STARTS WITH /STARTCVC //
// 1 MINUTE COUNTDOWN WILL BE STARTED UNTIL THE EVENT STARTS //
// PLAYERS CAN JOIN THE EVENT BY TYPING /JOIN //
// ONCE PLAYER TYPE /JOIN THEY WILL BE TELEPORTED TO A LAOOBY UNTILL THE COUNTDOWN FINISHES //
// IF LESS THAN 2 PLAYERS JOINED THE EVENT IT WILL BE CANCELED //
// ONE CRIMINAL WILL BE SELECTED RANDOMLY AND THE OTHR PLAYERS WILL BE SET TO COPS //
//...

#include <a_samp>
#include <foreach>
#include <zcmd>
#include <sscanf2>
#include <streamer>

#define     CIVILIAN    0
#define     COP			1
#define     CRIMINAL    2

#define     IN_CVC      1

new bool:CvC = false;
new CvC_Status;
new pStatus[MAX_PLAYERS];
new CvCpCount;
new Iterator:PlayersInCVC<MAX_PLAYERS>;
new CVC_VEH[MAX_PLAYERS];


enum e_spawns
{
	Float:spawnPos[3],
	spawnUsed
}
new spawns[][e_spawns] =
{
         {{2618.4744, -2204.1370, 13.3695},0},
         {{2613.1169, -2203.7178, 13.3695},0},
         {{2607.8311, -2203.6399, 13.3695},0},
         {{2602.7195, -2203.6812, 13.3695},0},
         {{2597.3818, -2203.6343, 13.3695},0},
         {{2597.3276, -2193.8452, 13.3695},0},
         {{2602.8567, -2194.4163, 13.3695},0},
         {{2608.0422, -2194.2698, 13.3695},0},
         {{2613.3118, -2194.6567, 13.3695},0},
         {{2618.9937, -2194.9639, 13.3695},0}
};

public OnFilterScriptInit()
{

	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}


public OnPlayerConnect(playerid)
{
	SetPlayerTeam(playerid, CIVILIAN);
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

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

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{

    return 0;
}

CMD:startcvc(playerid, params[])
{
	if(CvC == true) return SendClientMessage(playerid, -1, "Cops versus Criminals event is already activated!");
	SendClientMessage(playerid, -1, "You have activated the Cops versus Criminals event!");
	SendClientMessageToAll( -1, "Cops versus Criminals event has been activated, Enter /join to take part.");
	SendClientMessageToAll( -1, "You have 1 minute to join the event before it starts!");
	CvC = true;
	SetTimer("StartCvC", 60000, false);
	return 1;
}

CMD:join(playerid, params[])
{
	if(CvC == false) return SendClientMessage(playerid, -1, "There are no running Cops vs Criminals events");
	if(CvC_Status == 1) return SendClientMessage(playerid, -1, "Cops vs Criminals event is already started you cant take part!");
	pStatus[playerid] = IN_CVC;
	CvCpCount++;
	Iter_Add(PlayersInCVC,playerid);
	SetPlayerPos(playerid, 1710.433715,-1669.379272,20.225049);
	SetPlayerInterior(playerid, 18);
	SendClientMessage(playerid, -1, "You have joined cops vs criminals event, You are teleported to the lobby.");
	return 1;
}

CMD:gotopos(playerid, params[])
{
    new string[75],  Float:X, Float:Y, Float:Z;
    if(sscanf(params, "fff", Float:X, Float:Y, Float:Z)) return SendClientMessage(playerid, -1, "Usage: /gotopos [X-Y-Z]");
    SetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
    format(string, sizeof string, "You are teleported to position 'X'%f 'Y'%f 'Z'%f", Float:X, Float:Y, Float:Z);
    SendClientMessage(playerid, -1, string);
    return 1;
}

CMD:goto(playerid, params[])
{
    new Float:x,Float:y,Float:z;
    if(!sscanf(params, "fff",x,y,z))
    SetPlayerPos(playerid, x,y,z);
    return 1;
}

Last edited by josh; 01/11/2019 at 11:07 AM.
josh is offline   Reply With Quote
Old 01/11/2019, 10:26 AM   #5
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 363
Reputation: 17
Default Re: OnPlayerDeath

Still not much information on what you want.

Anyways, here's what I've perceived:

Code:
enum e_spawns
{
	Float:spawnX,
    Float:spawnY,
    Float:spawnZ,
    Float:spawnAngle,
	spawnUsed
}
new spawns[][e_spawns] =
{
         {{2618.4744, -2204.1370, 13.3695},0},
         {{2613.1169, -2203.7178, 13.3695},0},
         {{2607.8311, -2203.6399, 13.3695},0},
         {{2602.7195, -2203.6812, 13.3695},0},
         {{2597.3818, -2203.6343, 13.3695},0},
         {{2597.3276, -2193.8452, 13.3695},0},
         {{2602.8567, -2194.4163, 13.3695},0},
         {{2608.0422, -2194.2698, 13.3695},0},
         {{2613.3118, -2194.6567, 13.3695},0},
         {{2618.9937, -2194.9639, 13.3695},0}
};


public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:x, Float:y, Float:z, SpawnIndex, Float:Angle;

    SpawnIndex = random(sizeof(spawns));
    x = spawns[SpawnIndex][spawnX];
    y = spawns[SpawnIndex][spawnY];
    z = spawns[SpawnIndex][spawnZ];
    Angle = spawns[SpawnIndex][spawnAngle];

	return 1;
}
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is offline   Reply With Quote
Old 01/11/2019, 10:27 AM   #6
josh
Little Clucker
 
Join Date: Jul 2019
Posts: 49
Reputation: 0
Default Re: OnPlayerDeath

Quote:
Originally Posted by Proxus View Post
Still not much information on what you want.

Anyways, here's what I've perceived:

Code:
enum e_spawns
{
	Float:spawnX,
    Float:spawnY,
    Float:spawnZ,
    Float:spawnAngle,
	spawnUsed
}
new spawns[][e_spawns] =
{
         {{2618.4744, -2204.1370, 13.3695},0},
         {{2613.1169, -2203.7178, 13.3695},0},
         {{2607.8311, -2203.6399, 13.3695},0},
         {{2602.7195, -2203.6812, 13.3695},0},
         {{2597.3818, -2203.6343, 13.3695},0},
         {{2597.3276, -2193.8452, 13.3695},0},
         {{2602.8567, -2194.4163, 13.3695},0},
         {{2608.0422, -2194.2698, 13.3695},0},
         {{2613.3118, -2194.6567, 13.3695},0},
         {{2618.9937, -2194.9639, 13.3695},0}
};


public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:x, Float:y, Float:z, SpawnIndex, Float:Angle;

    SpawnIndex = random(sizeof(spawns));
    x = spawns[SpawnIndex][spawnX];
    y = spawns[SpawnIndex][spawnY];
    z = spawns[SpawnIndex][spawnZ];
    Angle = spawns[SpawnIndex][spawnAngle];

	return 1;
}
I Will test it
josh is offline   Reply With Quote
Old 01/11/2019, 11:02 AM   #7
josh
Little Clucker
 
Join Date: Jul 2019
Posts: 49
Reputation: 0
Default Re: OnPlayerDeath

Quote:
Originally Posted by Proxus View Post
Still not much information on what you want.

Anyways, here's what I've perceived:

Code:
enum e_spawns
{
	Float:spawnX,
    Float:spawnY,
    Float:spawnZ,
    Float:spawnAngle,
	spawnUsed
}
new spawns[][e_spawns] =
{
         {{2618.4744, -2204.1370, 13.3695},0},
         {{2613.1169, -2203.7178, 13.3695},0},
         {{2607.8311, -2203.6399, 13.3695},0},
         {{2602.7195, -2203.6812, 13.3695},0},
         {{2597.3818, -2203.6343, 13.3695},0},
         {{2597.3276, -2193.8452, 13.3695},0},
         {{2602.8567, -2194.4163, 13.3695},0},
         {{2608.0422, -2194.2698, 13.3695},0},
         {{2613.3118, -2194.6567, 13.3695},0},
         {{2618.9937, -2194.9639, 13.3695},0}
};


public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:x, Float:y, Float:z, SpawnIndex, Float:Angle;

    SpawnIndex = random(sizeof(spawns));
    x = spawns[SpawnIndex][spawnX];
    y = spawns[SpawnIndex][spawnY];
    z = spawns[SpawnIndex][spawnZ];
    Angle = spawns[SpawnIndex][spawnAngle];

	return 1;
}
I have some warning.

Code:
Code:
C:\Users\Desktop\SAMP\gamemodes\pVsC.pwn(91) : warning 204: symbol is assigned a value that is never used: "Angle"
C:\Users\Desktop\SAMP\gamemodes\pVsC.pwn(90) : warning 204: symbol is assigned a value that is never used: "z"
C:\Users\Desktop\SAMP\gamemodes\pVsC.pwn(89) : warning 204: symbol is assigned a value that is never used: "y"
C:\Users\Desktop\SAMP\gamemodes\pVsC.pwn(88) : warning 204: symbol is assigned a value that is never used: "x"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase
josh is offline   Reply With Quote
Old 01/11/2019, 11:07 AM   #8
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 363
Reputation: 17
Default Re: OnPlayerDeath

Quote:
Originally Posted by josh View Post
I have some warning.

Code:
Code:
C:\Users\Desktop\SAMP\gamemodes\pVsC.pwn(91) : warning 204: symbol is assigned a value that is never used: "Angle"
C:\Users\Desktop\SAMP\gamemodes\pVsC.pwn(90) : warning 204: symbol is assigned a value that is never used: "z"
C:\Users\Desktop\SAMP\gamemodes\pVsC.pwn(89) : warning 204: symbol is assigned a value that is never used: "y"
C:\Users\Desktop\SAMP\gamemodes\pVsC.pwn(88) : warning 204: symbol is assigned a value that is never used: "x"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase
My bad, I forgot.

Code:
SetSpawnInfo(playerid, GetPlayerTeam(playerid), GetPlayerSkin(playerid), x, y, z, Angle, 0, 0, 0, 0, 0, 0);
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is offline   Reply With Quote
Old 01/11/2019, 11:10 AM   #9
josh
Little Clucker
 
Join Date: Jul 2019
Posts: 49
Reputation: 0
Default Re: OnPlayerDeath

Quote:
Originally Posted by Proxus View Post
My bad, I forgot.

Code:
SetSpawnInfo(playerid, GetPlayerTeam(playerid), GetPlayerSkin(playerid), x, y, z, Angle, 0, 0, 0, 0, 0, 0);
Where I put this?
josh is offline   Reply With Quote
Old 01/11/2019, 11:15 AM   #10
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 363
Reputation: 17
Default Re: OnPlayerDeath

Quote:
Originally Posted by josh View Post
Where I put this?
In the OnPlayerDeath callback, like this:

Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:x, Float:y, Float:z, SpawnIndex, Float:Angle;

    SpawnIndex = random(sizeof(spawns));
    x = spawns[SpawnIndex][spawnX];
    y = spawns[SpawnIndex][spawnY];
    z = spawns[SpawnIndex][spawnZ];
    Angle = spawns[SpawnIndex][spawnAngle];

    SetSpawnInfo(playerid, GetPlayerTeam(playerid), GetPlayerSkin(playerid), x, y, z, Angle, 0, 0, 0, 0, 0, 0);

	return 1;
}
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OnPlayerDeath Drago987 Scripting Help 15 29/01/2014 05:21 PM
OnPlayerDeath []Allex[] Scripting Help 1 26/01/2013 08:05 PM
OnPlayerDeath HELP brightas Scripting Help 1 03/11/2012 11:13 AM
OnPlayerDeath Blackazur Scripting Help 6 15/09/2012 09:46 AM
OnPlayerDeath Qaiis Scripting Help 1 08/09/2012 11:39 AM


All times are GMT. The time now is 03:26 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.