no error

Started by Cool, Nov 02, 2015, 08:18 PM

Previous topic - Next topic

Cool

i try to much to fix it but i dont know why its not works no error on console
if ( cmd == "team" )
    {
  local plr = FindPlayer( GetTok( text, " ", 1 ) );
  if ( stats[ player.ID ].Team == true ) ePrivMessage( player, "[Error] You already have a team." );
  else if ( !text ) ePrivMessage( player, "Syntax: /team <player name or id>" );
  else if ( !plr ) ePrivMessage( player, "[Error] Unknown player." );
  else if ( stats[ plr.ID ].Team == true ) ePrivMessage( player, "[Error] " + plr.Name + " is already in a team." );
  else if ( stats[ player.ID ].Request == true ) ePrivMessage( player, "[Error] You already have a request." );
  else if ( stats[ plr.ID ].Request == true ) ePrivMessage( player, "[Error] " + plr.Name + " already have a request." );
  else
  {
   if ( stats[ player.ID ].TimeRequest < time() ) {
   stats[ player.ID ].Request = false;
   stats[ player.ID ].Partner = null; 
   stats[ player.ID ].TimeRequest = 0;
   stats[ plr.ID ].Request = false;
   stats[ plr.ID ].Partner = null;
   stats[ plr.ID ].TimeRequest = 0;
   }
   ePrivMessage( plr, "[!] " + player.Name + " would like to team up with you." );
   ePrivMessage( player, "Request submitted." );
   stats[ player.ID ].Partner = plr;
   stats[ plr.ID ].Partner = player;
   stats[ player.ID ].TimeRequest = time() + 30;
   stats[ plr.ID ].TimeRequest = time() + 30;
   stats[ plr.ID ].Request = true;
   stats[ player.ID ].Request = true;
  }
 }

Thijn

So, What's not working?

Cool

{UPDATE}when i type only /team its works its requests came to me but i try to send  to another one with /team 0 its says ID does not exists no specific line i noticed it when i try to catch error

Xmair

Change:
local plr = FindPlayer( GetTok( text, " ", 1 ) );
To
local plr = GetPlayer( GetTok( text, " ", 1 ) );
I hope you have a getplayer function.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Cool

thanks but now
but you say him check code again his works but mine not working

Quote from: Zeeshan.Bhatti on Aug 24, 2015, 08:13 PMSorry for double posting...


AN ERROR HAS OCCURED [Unexpected argument in FindPlayer: must be integer or string]
CALLSTACK
*FUNCTION [onPlayerCommand()] Cmds.nut line [978]..

/team & accept commands are working. But, /deny & leave commands not working...

And the line is

local plr = FindPlayer( pinfo[ player.ID ].Partner );
same problem in deny&leave command...
else if ( cmd == "accept" )
{
local plr = FindPlayer( stats[ player.ID ].Partner );
if ( stats[ player.ID ].Request == false ) MessagePlayer( "[Error] You don't have a request.", player );
else if ( stats[ player.ID ].Team == true ) MessagePlayer( "[Error] You already have a team-mate.", player );
else
{
if ( stats[ player.ID ].TimeRequest < time() ) {
MessagePlayer( "[Error] Time ended.", player );
stats[ player.ID ].Request = false;
stats[ player.ID ].Partner = null;
stats[ plr.ID ].Request = false;
stats[ plr.ID ].Partner = null;
stats[ player.ID ].TimeRequest = 0;
stats[ plr.ID ].TimeRequest = 0;
} else {

MessagePlayer( "[!] " + player.Name + " is doing team with you.", player );
MessagePlayer( "Request Accepted! You are now teaming with " + plr.Name, player );
stats[ player.ID ].Team = true;
stats[ plr.ID ].Team = true;
stats[ player.ID ].Request = false;
stats[ plr.ID ].Request = false;
stats[ player.ID ].TimeRequest = 0;
stats[ plr.ID ].TimeRequest = 0;
player.Pos = plr.Pos;
}
}
}

else if ( cmd == "deny" )
{
local plr = GetPlayer( stats[ player.ID ].Partner );
if ( stats[ player.ID ].Request == false ) MessagePlayer2( "[Error] You don't have a request.", player );
else
{
if ( stats[ player.ID ].TimeRequest < time() ) {
MessagePlayer( "[Error] Time ended.", player );
stats[ player.ID ].Request = false;
stats[ plr.ID ].Request = false;
stats[ player.ID ].Partner = null;
stats[ plr.ID ].Partner = null;
stats[ player.ID ].TimeRequest = 0;
stats[ plr.ID ].TimeRequest = 0;
}

MessagePlayer( "[!] " + plr.Name + " denied your request.", player );
MessagePlayer( "Request Denied.", player );
stats[ player.ID ].Request = false;
stats[ plr.ID ].Request = false;
stats[ player.ID ].TimeRequest = 0;
stats[ plr.ID ].TimeRequest = 0;
}
}

Xmair

Try changing findplayer with getplayer again.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Cool

i do it already but when i type accept you dont have any request say i have a request but say you dont have no error on console when i change it

SAzEe21



else if ( cmd == "accept" )
{
local plr = FindPlayer( pinfo[ player.ID ].Partner );
if ( pinfo[ player.ID ].Request == false ) PrivMessage( "[Team] You don't have a team request.", player );
else if ( pinfo[ player.ID ].Team == true ) PrivMessage( "[Team] You already have a team-mate.", player );
else
{
if ( pinfo[ player.ID ].TimeRequest < time() ) {
PrivMessage( "[Time] Team requesting time is over.", player );
pinfo[ player.ID ].Request = false;
pinfo[ player.ID ].Partner = null;
pinfo[ plr.ID ].Request = false;
pinfo[ plr.ID ].Partner = null;
pinfo[ player.ID ].TimeRequest = 0;
pinfo[ plr.ID ].TimeRequest = 0;
} else {

PrivMessage( "[Accept] " + player.Name + " has accepting your team request.", player );
PrivMessage( "[Accept] You are now teaming with " + plr.Name, player );
pinfo[ player.ID ].Team = true;
pinfo[ plr.ID ].Team = true;
pinfo[ player.ID ].Request = false;
pinfo[ plr.ID ].Request = false;
pinfo[ player.ID ].TimeRequest = 0;
pinfo[ plr.ID ].TimeRequest = 0;
player.Pos = plr.Pos;
}
}
}

else if ( cmd == "deny" )
{
local plr = FindPlayer( pinfo[ player.ID ].Partner );
if ( pinfo[ player.ID ].Request == false ) PrivMessage( "[Team] You don't have a team request.", player );
else
{
if ( pinfo[ player.ID ].TimeRequest < time() )
{
PrivMessage( "[Time] Team requesting time is over.", player );
pinfo[ player.ID ].Request = false;
pinfo[ plr.ID ].Request = false;
pinfo[ player.ID ].Partner = null;
pinfo[ plr.ID ].Partner = null;
pinfo[ player.ID ].TimeRequest = 0;
pinfo[ plr.ID ].TimeRequest = 0;
}

PrivMessage( "[Denied] " + plr.Name + " has denied your team request.", player );
PrivMessage( "[Denied]Request Denied.", player );
pinfo[ player.ID ].Request = false;
pinfo[ plr.ID ].Request = false;
pinfo[ player.ID ].TimeRequest = 0;
pinfo[ plr.ID ].TimeRequest = 0;
}
}

Change PrivMessage to MessagePlayer

Cool


Cool

Thanks to all who help
solved by zeeshan ;)