[HELP] lower life -
Bocha - 31.03.2014
hello friends I have a problem, I need to know how to give life to another player down while often squeezed right click (me down my life for the moment) also need to know how to add 2 to give money 2000 score and q increasingly squeezed click right
Code that happened to me (I lower my life)
if(gTeam[playerid] == TEAM_ZOMBIES)
{
if(newkeys == KEY_AIM)
{
new Float:Vida;
GetPlayerHealth(playerid, Health);
SetPlayerHealth(playerid, Health-10);
}
}
Re: [HELP] lower life -
ZeroTheScyther - 31.03.2014
Try [ pawn ] on the code ... anyway the code you just made it's a bit wrong ... what you mad should be like "When a player presses right click, his health gets lowered." You want to make a zombie bite system so it should work like this...
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) //enter shop
{
if(newkeys == KEY_AIM)
{
if(gTeam[playerid] == TEAM_ZOMBIES)
{
if(GetDistanceBetweenPlayers(playerid,playerid2) < 3)
{
if(gTeam[playerid2] !=TEAM_ZOMBIES)
{
GetPlayerHealth(playerid2, Health);
SetPlayerHealth(playerid2, Health-10);
}
}
}
}
return 1
}
stock GetDistanceBetweenPlayers(playerid,playerid2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(playerid2,x2,y2,z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return floatround(tmpdis);
}
I think it's wrong but it's worth trying.
Respuesta: [HELP] lower life -
Bocha - 31.03.2014
I get these 4 errors
C:\Users\Usuario\Desktop\The walking dead Primera Temporada\gamemodes\Thewalkingdead.pwn(7717) : error 017: undefined symbol "GetDistanceBetweenPlayers"
C:\Users\Usuario\Desktop\The walking dead Primera Temporada\gamemodes\Thewalkingdead.pwn(7719) : error 017: undefined symbol "playerid2"
C:\Users\Usuario\Desktop\The walking dead Primera Temporada\gamemodes\Thewalkingdead.pwn(7721) : error 017: undefined symbol "playerid2"
C:\Users\Usuario\Desktop\The walking dead Primera Temporada\gamemodes\Thewalkingdead.pwn(7722) : error 017: undefined symbol "playerid2"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
7717 - if(GetDistanceBetweenPlayers(playerid,playerid2) < 3)
7719 - if(gTeam[playerid2] !=TEAM_ZOMBIES)
7721 -GetPlayerHealth(playerid2, Health);
7722 - SetPlayerHealth(playerid2, Health-10);
Re: [HELP] lower life -
ZeroTheScyther - 31.03.2014
pawn Код:
C:\Users\Usuario\Desktop\The walking dead Primera Temporada\gamemodes\Thewalkingdead.pwn(7717) : error 017: undefined symbol "GetDistanceBetweenPlayers"
add
pawn Код:
stock GetDistanceBetweenPlayers(playerid,playerid2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(playerid2,x2,y2,z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return floatround(tmpdis);
}
somewhere at the end of your script.
It also had some errors. Fixed them now
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) //enter shop
{
new playerid2;
new Health = GetPlayerHealth(playerid2);
if(newkeys == 128)
{
if(gTeam[playerid] == TEAM_ZOMBIES)
{
if(GetDistanceBetweenPlayers(playerid,playerid2) < 3)
{
if(gTeam[playerid2] !=TEAM_ZOMBIES)
{
SetPlayerHealth(playerid2, Health-10);
}
}
}
}
return 1;
}
stock GetDistanceBetweenPlayers(playerid,playerid2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(playerid2,x2,y2,z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return floatround(tmpdis);
}
Respuesta: [HELP] lower life -
Bocha - 31.03.2014
I dropped to 1 error and 1 warning
C:\Users\Usuario\Desktop\The walking dead Primera Temporada\gamemodes\Thewalkingdead.pwn(7714) : warning 202: number of arguments does not match definition
C:\Users\Usuario\Desktop\The walking dead Primera Temporada\gamemodes\Thewalkingdead.pwn(7719) : error 017: undefined symbol "GetDistanceBetweenPlayers"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
7714 - new Health = GetPlayerHealth(playerid2);
7719 - if(GetDistanceBetweenPlayers(playerid,playerid2) < 3)
Re: [HELP] lower life -
ZeroTheScyther - 31.03.2014
You still didn't added the damn stock ...
Respuesta: [HELP] lower life -
Bocha - 31.03.2014
q add everything I went through and still the same.
C:\Users\Usuario\Desktop\The walking dead Primera Temporada\gamemodes\Thewalkingdead.pwn(7714) : warning 202: number of arguments does not match definition
C:\Users\Usuario\Desktop\The walking dead Primera Temporada\gamemodes\Thewalkingdead.pwn(7719) : error 017: undefined symbol "GetDistanceBetweenPlayers"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
7714 - new Health = GetPlayerHealth(playerid2);
7719 - if(GetDistanceBetweenPlayers(playerid,playerid2) < 3)
Respuesta: [HELP] lower life -
Bocha - 01.04.2014
as I solve please help
Re: [HELP] lower life -
Crayder - 01.04.2014
Quote:
Originally Posted by ZeroTheScyther
pawn Код:
C:\Users\Usuario\Desktop\The walking dead Primera Temporada\gamemodes\Thewalkingdead.pwn(7717) : error 017: undefined symbol "GetDistanceBetweenPlayers"
add
pawn Код:
stock GetDistanceBetweenPlayers(playerid,playerid2) { new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetPlayerPos(playerid,x1,y1,z1); GetPlayerPos(playerid2,x2,y2,z2); tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); return floatround(tmpdis); }
somewhere at the end of your script.
It also had some errors. Fixed them now
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) //enter shop { new playerid2; new Health = GetPlayerHealth(playerid2); if(newkeys == 128) { if(gTeam[playerid] == TEAM_ZOMBIES) { if(GetDistanceBetweenPlayers(playerid,playerid2) < 3) { if(gTeam[playerid2] !=TEAM_ZOMBIES) { SetPlayerHealth(playerid2, Health-10); } } } } return 1; }
stock GetDistanceBetweenPlayers(playerid,playerid2) { new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetPlayerPos(playerid,x1,y1,z1); GetPlayerPos(playerid2,x2,y2,z2); tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); return floatround(tmpdis); }
|
In your case, who is playerid2? Maybe the closest player to the player pressing the key?
Use this code instead:
pawn Код:
stock Float:GetDistanceBetweenPlayers(playerid, playerid2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(playerid2,x2,y2,z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return tmpdis;
}
/*stock bool:IsPlayerInRangeOfPlayer(playerid, playerid2, Float:range) //An extension if you want it.
{
if(GetDistanceBetweenPlayers(playerid, playerid2) <= range) return true;
return false;
}*/
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == 128)
{
if(gTeam[playerid] == TEAM_ZOMBIES)
{
foreach(Player, playerid2)
{
if((GetDistanceBetweenPlayers(playerid, playerid2) <= 3) && (gTeam[playerid2] !=TEAM_ZOMBIES))
{
new Health; GetPlayerHealth(playerid2, Health);
SetPlayerHealth(playerid2, Health-10);
}
}
}
}
return 1;
}
Re: [HELP] lower life -
ZeroTheScyther - 01.04.2014
Quote:
Originally Posted by Crayder
In your case, who is playerid2? Maybe the closest player to the player pressing the key?
Use this code instead:
pawn Код:
stock Float:GetDistanceBetweenPlayers(playerid, playerid2) { new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetPlayerPos(playerid,x1,y1,z1); GetPlayerPos(playerid2,x2,y2,z2); tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); return tmpdis; } /*stock bool:IsPlayerInRangeOfPlayer(playerid, playerid2, Float:range) //An extension if you want it. { if(GetDistanceBetweenPlayers(playerid, playerid2) <= range) return true; return false; }*/ public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(newkeys == 128) { if(gTeam[playerid] == TEAM_ZOMBIES) { foreach(Player, playerid2) { if((GetDistanceBetweenPlayers(playerid, playerid2) <= 3) && (gTeam[playerid2] !=TEAM_ZOMBIES)) { new Health; GetPlayerHealth(playerid2, Health); SetPlayerHealth(playerid2, Health-10); } } } } return 1; }
|
Pretty much what he wants to make is "When player1 is close to player2 and player1 presses RIGHT CLICK, player2 loses 10 HP" .. anyway he'll need to make a timer to make this unspammable and other things ... I just wanted to give him an ideea and not the whole code ...