CallRemotefunction(server-sided money)
#1

So I want to do a callremotefunction from a filterscript but I'm kinda lost in the function of my givemoney.
So here is the code how I give money to players(server-sided) from sharemoney command:
Код:
	pInfo[targetid][pMoney] += givemoney;
				pInfo[playerid][pMoney] -= givemoney;
My stock function of givemoney:
Код:
stock GiveMoney(playerid,money)
{
    if(HalloweenMode == 1)
    {
        money += 2500;
		ShowNotMsg(playerid, money, 2, 1);
		pInfo[playerid][pMoney] += money;
	}
	else
	{
	    if(DowntimeMode == 1)
	    {
	        money += 8500;
			ShowNotMsg(playerid, money, 5, 1);
			pInfo[playerid][pMoney] += money;
		}
		else
		{
		    if(ChristmasMode == 1)
		    {
		        if(pInfo[playerid][pVipLevel] >= 1)
		        {
	      			money += 4500;
					ShowNotMsg(playerid, money, 3, 1);
					pInfo[playerid][pMoney] += money;
				}
				else
				{
 					money += 2500;
					ShowNotMsg(playerid, money, 2, 1);
					pInfo[playerid][pMoney] += money;
				}
			}
			else
			{
				ShowNotMsg(playerid, money, 0, 1);
				pInfo[playerid][pMoney] += money;
			}
		}
	}
	return 1;
}

Now from the filterscript this is where I have my doubts , would this code work?
Код:
CallRemoteFunction(GiveMoney(i(orplayerid), 10000);
or do I have to do something else?

Also how would I check if the player is admin with callremotefunction? would this do ? well I know its pretty messed up just asking if it would work or is there any other check.
Код:
CallRemoteFunction(if(pInfo[playerid][pAdminLevel] >= 1));
Reply
#2

You're using CallRemoteFunction with incorrect parameters.

https://sampwiki.blast.hk/wiki/CallRemoteFunction

Example Usage:
PHP код:
forward CallMe(number, const string[]);
public 
CallMe(number, const string[])
{
    
printf("CallMe called. Int: %i  String: %s."numberstring);
    return 
1;
}
 
// Somewhere... in another file perhaps?
CallRemoteFunction("CallMe""is"69"this is a string"); 
Reply
#3

Well, CallRemoteFunction calls a forwarded and public function not stock...
you can return a value in ur public function and callremotefunction will return this value for you.

so it would be:

PHP код:
forward public GiveMoney(playerid,money);
public 
GiveMoney(playerid,money)
{
    if(
HalloweenMode == 1)
    {
        
money += 2500;
        
ShowNotMsg(playeridmoney21);
        
pInfo[playerid][pMoney] += money;
    }
    else
    {
        if(
DowntimeMode == 1)
        {
            
money += 8500;
            
ShowNotMsg(playeridmoney51);
            
pInfo[playerid][pMoney] += money;
        }
        else
        {
            if(
ChristmasMode == 1)
            {
                if(
pInfo[playerid][pVipLevel] >= 1)
                {
                      
money += 4500;
                    
ShowNotMsg(playeridmoney31);
                    
pInfo[playerid][pMoney] += money;
                }
                else
                {
                     
money += 2500;
                    
ShowNotMsg(playeridmoney21);
                    
pInfo[playerid][pMoney] += money;
                }
            }
            else
            {
                
ShowNotMsg(playeridmoney01);
                
pInfo[playerid][pMoney] += money;
            }
        }
    }
    return 
1;

and later

PHP код:
CallRemoteFunction("GiveMoney""id"i(orplayerid), 10000); 
also you can make a function like this which returns the level:

PHP код:
forward public GetPlayerLevelz(playerid);
public 
GetPlayerLevelz(playerid)
{
    return 
pInfo[playerid][pAdminLevel];

and will be able to check player level like that:
PHP код:
if(CallRemoteFunction("GetPlayerLevelz""i"playerid) > 0)
{

hope that helped xd.
Reply
#4

Quote:
Originally Posted by jlalt
Посмотреть сообщение
Well, CallRemoteFunction calls a forwarded and public function not stock...
you can return a value in ur public function and callremotefunction will return this value for you.

so it would be:

PHP код:
forward public GiveMoney(playerid,money);
public 
GiveMoney(playerid,money)
{
    if(
HalloweenMode == 1)
    {
        
money += 2500;
        
ShowNotMsg(playeridmoney21);
        
pInfo[playerid][pMoney] += money;
    }
    else
    {
        if(
DowntimeMode == 1)
        {
            
money += 8500;
            
ShowNotMsg(playeridmoney51);
            
pInfo[playerid][pMoney] += money;
        }
        else
        {
            if(
ChristmasMode == 1)
            {
                if(
pInfo[playerid][pVipLevel] >= 1)
                {
                      
money += 4500;
                    
ShowNotMsg(playeridmoney31);
                    
pInfo[playerid][pMoney] += money;
                }
                else
                {
                     
money += 2500;
                    
ShowNotMsg(playeridmoney21);
                    
pInfo[playerid][pMoney] += money;
                }
            }
            else
            {
                
ShowNotMsg(playeridmoney01);
                
pInfo[playerid][pMoney] += money;
            }
        }
    }
    return 
1;

and later

PHP код:
CallRemoteFunction("GiveMoney""id"i(orplayerid), 10000); 
also you can make a function like this which returns the level:

PHP код:
forward public GetPlayerLevelz(playerid);
public 
GetPlayerLevelz(playerid)
{
    return 
pInfo[playerid][pAdminLevel];

and will be able to check player level like that:
PHP код:
if(CallRemoteFunction("GetPlayerLevelz""i"playerid) > 0)
{

hope that helped xd.
Pretty good explanation thank you but about the money lets say I can do this?
PHP код:
CallRemoteFunction("GiveMoney""id",playerid10000); 
or
PHP код:
CallRemoteFunction("GiveMoney""id"i10000); 
Reply
#5

You can pass anything.
Reply
#6

Quote:
Originally Posted by Crystallize
Посмотреть сообщение
Pretty good explanation thank you but about the money lets say I can do this?
PHP код:
CallRemoteFunction("GiveMoney""id",playerid10000); 
or
PHP код:
CallRemoteFunction("GiveMoney""id"i10000); 
yup, both supposed to work perfectly.
Reply
#7

Quote:
Originally Posted by OneDay
Посмотреть сообщение
You can pass anything.
Yes I know but would that work?
-----
Thanks a ton jlalt
Reply
#8

Yes it will work when i or playerid and whatever is a valid player id
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)