Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Minor command problem

 
Post new topic   Reply to topic Printable version
 View previous topic  Wireless router and ASSS Post :: Post ship gfx  View next topic  
Author Message
Reaem
Newbie


Joined: Oct 02 2005
Posts: 9
Offline

PostPosted: Sat Mar 01, 2008 9:23 pm    Post subject: Minor command problem Reply to topic Reply with quote

Simple donate command: should transfer the entered amount of points from you to the target player

Problem: whenever I send this in public it works as entered, but when sending this privately to another player on my server, the command does not register at all. It doesn't even show up in my console log that the command was received. What am I missing?

Code: Show/Hide

local void Cdonate(const char *tc, const char *params, Player *p, const Target *target)
{
   if (target->type != T_PLAYER || params == NULL)
   {
      chat->SendMessage(p, "Usage: ?donate # privately to a player");
      return;
   }
   else
   {   
      int cost = atoi(params);
      if (check_pts(p, cost))
      {
          int p_pts = stats->GetStat(p, STAT_FLAG_POINTS, INTERVAL_RESET);
             stats->SetStat(p, STAT_FLAG_POINTS, INTERVAL_RESET, p_pts - cost);
             int t_pts = stats->GetStat(target->u.p, STAT_FLAG_POINTS, INTERVAL_RESET);
             stats->SetStat(target->u.p, STAT_FLAG_POINTS, INTERVAL_RESET, t_pts + cost);
             chat->SendMessage(p, "You have donated your points");
             chat->SendMessage(target->u.p, "You have received a donation");
       }      
      else
      {
         chat->SendMessage(p, "Not enough points");
         return;
      }
   }
}
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Sat Mar 01, 2008 9:28 pm    Post subject: Reply to topic Reply with quote

im not a programmer but i was learnin c++ 2 years ago and quit, so correct me if im wrong

the code u wrote

else
{
chat->SendMessage(p, "Not enough points");
return;

shouldnt it be ?

else if
{
chat->SendMessage(p, "Not enough points");
return;
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Sat Mar 01, 2008 10:41 pm    Post subject: Reply to topic Reply with quote

hellzlaker wrote:
im not a programmer but i was learnin c++ 2 years ago and quit, so correct me if im wrong

the code u wrote

else
{
chat->SendMessage(p, "Not enough points");
return;

shouldnt it be ?

else if
{
chat->SendMessage(p, "Not enough points");
return;


No.



Don't you need to register the command to be listened to?
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sat Mar 01, 2008 10:53 pm    Post subject: Reply to topic Reply with quote

Make sure you've got privcmd_donate in the appropriate groupdef file, in addition to the cmd_donate one.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Sat Mar 01, 2008 11:20 pm    Post subject: Reply to topic Reply with quote

points is just flag points?
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Reaem
Newbie


Joined: Oct 02 2005
Posts: 9
Offline

PostPosted: Sun Mar 02, 2008 11:11 am    Post subject: o Reply to topic Reply with quote

Oh. that's undoubtedy the problem then, thanks mr brain. I take it all commands must be listed once for each target it can be use on then, IE freqcmd_donate too? Or just for priv commands?
(Of course I am not going to allow someone to donate to a whole freq, but for educational purposes)
And no, points include kill and flag points together. The reason I consolidate those points via consolidate(p) into flag points is so I can more easily manipulate the numbers.
-JP
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sun Mar 02, 2008 11:13 am    Post subject: Reply to topic Reply with quote

Freq commands fall under the privcmd_* designation. You'll have to fix your code to make sure the target is a player, otherwise you'll probably crash.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sun Mar 02, 2008 11:30 am    Post subject: Reply to topic Reply with quote

Instead of GetStat/SetStat you may want to use IncrementStat to avoid race conditions. Despite its name you can pass in a negative amount.
_________________
ss news
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Agile
Guest


Offline

PostPosted: Tue Mar 04, 2008 9:15 pm    Post subject: Reply to topic Reply with quote

Glad you told me that, thanks smong =)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 23 page(s) served in previous 5 minutes.

phpBB Created this page in 1.391079 seconds : 31 queries executed (98.2%): GZIP compression disabled