Need Help with Trucker job [2]
#1

Hey guys, with my previous post, ive only found that im not getting money because of anticheat, and the server is based on mysql but the filterscript of the job isnt. so i would really appreciate if anyone can define my /givemoney into the filterscript so that i can make it work on server to get money after the job is done. ill leave the scripts below. i really really appreciate the help and will also give +rep . Thanks.

My /givemoney command
Код HTML:
CMD:givemoney(playerid, params[])
{
    new targetid, amount;

    if(PlayerInfo[playerid][pAdmin] < 7)
    {
        return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    }
    if(sscanf(params, "ui", targetid, amount))
    {
        return SendClientMessage(playerid, COLOR_SYNTAX, "USAGE: /givemoney [playerid] [amount]");
    }
    if(!IsPlayerConnected(targetid))
    {
        return SendClientMessage(playerid, COLOR_GREY, "The player specified is disconnected.");
    }
    if(!PlayerInfo[targetid][pLogged])
    {
        return SendClientMessage(playerid, COLOR_GREY, "That player hasn't logged in yet.");
    }

    GivePlayerCash(targetid, amount);
    SendAdminMessage(COLOR_LIGHTRED, "AdmCmd: %s has given %s to %s.", GetPlayerRPName(playerid), FormatNumber(amount), GetPlayerRPName(targetid));
    Log_Write("log_givemoney", "%s (uid: %i) has used /givemoney to give $%i to %s (uid: %i).", GetPlayerNameEx(playerid), PlayerInfo[playerid][pID], amount, GetPlayerNameEx(targetid), PlayerInfo[targetid][pID]);
    return 1;
}
Stock give playercash
Код HTML:
forward GivePlayerCash(playerid, amount);
public GivePlayerCash(playerid, amount)
{
    if(PlayerInfo[playerid][pLogged])
    {
        PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash] + amount;
        if(amount < 0)
        {
            mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET money_spent = money_spent + %i WHERE uid = %i", -amount, PlayerInfo[playerid][pID]);
            mysql_tquery(connectionID, queryBuffer);

            mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "SELECT uid FROM users WHERE uid = %i AND money_spent >= 500000", PlayerInfo[playerid][pID]);
            mysql_tquery(connectionID, queryBuffer, "OnPlayerCheckMoney", "is", playerid, "I'm rich!");
        }
        else if(amount > 0)
        {
            mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET money_earned = money_earned + %i WHERE uid = %i", amount, PlayerInfo[playerid][pID]);
            mysql_tquery(connectionID, queryBuffer);

            mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "SELECT uid FROM users WHERE uid = %i AND money_earned >= 500000", PlayerInfo[playerid][pID]);
            mysql_tquery(connectionID, queryBuffer, "OnPlayerCheckMoney", "is", playerid, "High roller");
        }

        mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET cash = cash + %i WHERE uid = %i", amount, PlayerInfo[playerid][pID]);
        mysql_tquery(connectionID, queryBuffer);
    }
    return 1;
}
Finally the filterscript i want to get working situation
Код HTML:
#include <a_samp>
#include <zcmd>


#define FILTERSCRIPT
#define COLOR_GREEN 0x33AA33FF
#define COLOR_YELLOW 0xFFFF00FF
#define COLOR_RED 0xFF0606FF


public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Trucker Job - Created by Cena44(Timon) ");
	print("--------------------------------------\n");
	CreateVehicle(414, 2512.1653, -2117.0974, 13.4788, 0.0000, 27, 78, 3000);
    CreateVehicle(414, 2506.7500, -2116.7947, 13.4788, 0.0000, 41, 42, 3000);
    CreateVehicle(414, 2482.2327, -2116.6165, 13.4788, 0.0000, 48, 72, 3000);
    CreateVehicle(456, 2463.3999, -2116.1843, 13.5200, 0.0000, 46, 89, 3000);
    CreateVehicle(456, 2457.8191, -2115.6475, 13.5200, 0.0000, 78, 27, 3000);
    CreateVehicle(456, 2488.4919, -2116.3032, 13.5200, 0.0000, 24, 78, 3000);
    CreatePickup(1239, 1, 2485.4292,-2120.2351,13.5469, 0); // Boxer Job
    Create3DTextLabel("Trucks Depot\n{FFFF00}/loadtruck to get load the truck", COLOR_RED, 2485.4292,-2120.2351,13.5469, 15, 0, 1);
    CreatePickup(1239, 1, 2460.3623,-2119.8494,13.5530, 0); // Boxer Job
    Create3DTextLabel("Trucks Depot\n{FFFF00}/loadtruck to get load the truck", COLOR_RED, 2460.3623,-2120.2351,13.5469, 15, 0, 1);
    CreatePickup(1239, 1, 2509.6421,-2120.6365,13.5469, 0); // Boxer Job
    Create3DTextLabel("Trucks Depot\n{FFFF00}/loadtruck to get load the truck", COLOR_RED, 2509.6421,-2120.2351,13.5469, 15, 0, 1);
	return 1;
}

CMD:loadtruck(playerid, params[])
{
  if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "You are not driving a truck from the depot.");
  if(!IsPlayerInRangeOfPoint(playerid, 7.5, 2485.4292,-2120.2351,13.5469) && !IsPlayerInRangeOfPoint(playerid, 7.5, 2460.3623,-2119.8494,13.5530)
	&& !IsPlayerInRangeOfPoint(playerid, 7.5, 2509.6421,-2120.6365,13.5469))
	{
	    SendClientMessage(playerid, COLOR_RED, "You are not near the loading place.");
	    return 1;
	}
  {
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Welcome to the factory, what would you like to deliver?", "{00B000}Drinks and Food($500) \n{00B000}Clothing($1000) \n{A70000}Drugs($1500) \n{A70000}Illegal Fire Arms($2000)", "Load Truck", "Cancel");
    return 1;
  }
  return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)// They pressed the first button.
    {
    switch(dialogid)
        {
		case 1:// Our dialog!
    	    {
           	switch(listitem)// Checking which listitem was selected
        	{
        	    case 0:// The first item listed
        	    {
        	        if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash to buy this products.");
        	        GivePlayerMoney(playerid, -500);
        	        SetPlayerCheckpoint(playerid, 2121.4949,-1781.8108,13.5618, 5.0);
        	        SendClientMessage(playerid, COLOR_YELLOW, "You have loaded some Food and drinks crates, deliver them to the Well Stacked Pizza Co. to get your pay. (Checkpoint)");
        	    }
        	    case 1: // The second item listed
        	    {
        	        if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash to buy this products.");
        	        GivePlayerMoney(playerid, -1000);
        	        SetPlayerCheckpoint(playerid, 2247.8418,-1661.3953,15.5455, 5.0);
        	        SendClientMessage(playerid, COLOR_YELLOW, "You have loaded some Clothes Boxes, deliver them to Binco to get your pay. (Checkpoint)");
        	    }
        	    case 2: // The third item listed
        	    {
        	        if(GetPlayerMoney(playerid) < 1500) return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash to buy this products.");
        	        GivePlayerMoney(playerid, -1500);
        	        SetPlayerCheckpoint(playerid, 2517.2693,-1274.5581,34.9548, 5.0);
        	        SendClientMessage(playerid, COLOR_YELLOW, "You have loaded some drug packages, deliver them to the Drug factory to get your pay. (Checkpoint)");
        	    }
        	     case 3: // The fourth item listed
        	    {
                    if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash to buy this products.");
    	            GivePlayerMoney(playerid, -2000);
        	        SetPlayerCheckpoint(playerid, 1362.9902,-1279.9124,13.6332, 5.0);
        	        SendClientMessage(playerid, COLOR_YELLOW, "You have loaded some weapon crates, deliver them to the Ammu-Nation to get your pay. (Checkpoint)");
        	    }
        	}
    	    }
	}
    }
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    if(!IsPlayerInVehicle(playerid, 2) && !IsPlayerInVehicle(playerid, 3) && !IsPlayerInVehicle(playerid, 4) && !IsPlayerInVehicle(playerid, 1)
	 && !IsPlayerInVehicle(playerid, 5) && !IsPlayerInVehicle(playerid, 6))
    {
            SendClientMessage(playerid,COLOR_RED,"You are not in the delivery truck.");
            return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid,5,2121.4949,-1781.8108,13.5618)) // Food and Drinks
		{
             SendClientMessage(playerid, COLOR_GREEN, "You have delivered the products and got payed $1000, good job.");
		     GivePlayerMoney(playerid, 1000);
		     DisablePlayerCheckpoint(playerid);
		}
    if(IsPlayerInRangeOfPoint(playerid,5,2247.8418,-1661.3953,15.5455)) // Clothing
		{
             SendClientMessage(playerid, COLOR_GREEN, "You have delivered the products and got payed $2000, good job.");
		     GivePlayerMoney(playerid, 2000);
		     DisablePlayerCheckpoint(playerid);
		}
    if(IsPlayerInRangeOfPoint(playerid,5,2517.2693,-1274.5581,34.9548)) // Drugs
		{
             SendClientMessage(playerid, COLOR_GREEN, "You have delivered the products and got payed $3000, good job.");
		     GivePlayerMoney(playerid, 3000);
		     DisablePlayerCheckpoint(playerid);
		}
    if(IsPlayerInRangeOfPoint(playerid,5,1362.9902,-1279.9124,13.6332)) // Illegal Fire Arms
		{
             SendClientMessage(playerid, COLOR_GREEN, "You have delivered the products and got payed $4000 and a special weapon with some bullets, good job.");
		     GivePlayerMoney(playerid, 4000);
		     GivePlayerWeapon(playerid, 24, 50);
		     DisablePlayerCheckpoint(playerid);
		}
    return 1;
}
Reply
#2

Calling remote function is one way. PVars is the other way.

You need to call from filterscript the public function `GivePlayerCash` of the gamemode. Replace `GivePlayerMoney` function to `GivePlayerMoneyEx` at the filterscript:
pawn Код:
// filterscript:
GivePlayerMoneyEx(playerid, amount)
{
    CallRemoteFunction("GivePlayerCash", "dd", playerid, amount);
}
The filterscript uses `GetPlayerMoney` function, you will need to add another remote function to get the value of the variable from the gamemode. I am sure you have a function to get the server-side money value in your gamemode but make it a public function:
pawn Код:
// gamemode:
forward GetPlayerCash(playerid);
public GetPlayerCash(playerid)
{
    return PlayerInfo[playerid][pCash];
}
At the filterscript now, replace `GetPlayerMoney` to `GetPlayerMoneyEx`.
pawn Код:
// filterscript:
GetPlayerMoneyEx(playerid)
{
    return CallRemoteFunction("GetPlayerCash", "d", playerid);
}
Reply
#3

Is there any way i could contact you ? where we can have text to text in real time ? I Have a public discord account if you can possibly add me. i wont bother you much.
Reply
#4

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Calling remote function is one way. PVars is the other way.

You need to call from filterscript the public function `GivePlayerCash` of the gamemode. Replace `GivePlayerMoney` function to `GivePlayerMoneyEx` at the filterscript:
pawn Код:
// filterscript:
GivePlayerMoneyEx(playerid, amount)
{
    CallRemoteFunction("GivePlayerCash", "dd", playerid, amount);
}
The filterscript uses `GetPlayerMoney` function, you will need to add another remote function to get the value of the variable from the gamemode. I am sure you have a function to get the server-side money value in your gamemode but make it a public function:
pawn Код:
// gamemode:
forward GetPlayerCash(playerid);
public GetPlayerCash(playerid)
{
    return PlayerInfo[playerid][pCash];
}
At the filterscript now, replace `GetPlayerMoney` to `GetPlayerMoneyEx`.
pawn Код:
// filterscript:
GetPlayerMoneyEx(playerid)
{
    return CallRemoteFunction("GetPlayerCash", "d", playerid);
}
It did work but the issue now is the weapon.. is there a way to fix this too? as you can see in filterscript, there is a line for giveweapon .. its not giving the weapon.. thanks for fixing the money issue.. +rep
Reply
#5

Can you post the functions you give/get weapons at your gamemode?
Reply
#6

CMD:givegun(playerid, params[])
{
new targetid, weaponid;

if(PlayerInfo[playerid][pAdmin] < 4)
{
return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
}
if(!PlayerInfo[playerid][pAdminDuty] && PlayerInfo[playerid][pAdmin] < 6)
{
return SendClientMessage(playerid, COLOR_GREY, "This command requires you to be on admin duty. /aduty to go on duty.");
}
if(sscanf(params, "ui", targetid, weaponid))
{
return SendClientMessage(playerid, COLOR_SYNTAX, "USAGE: /givegun [playerid] [weaponid]");
}
if(!IsPlayerConnected(targetid))
{
return SendClientMessage(playerid, COLOR_GREY, "The player specified is disconnected.");
}
if(PlayerInfo[targetid][pHours] < 2 || PlayerInfo[targetid][pWeaponRestricted] > 0)
{
return SendClientMessage(playerid, COLOR_GREY, "That player is either weapon restricted or played less than two playing hours.");
}
if(!(1 <= weaponid <= 46))
{
return SendClientMessage(playerid, COLOR_GREY, "Invalid weapon.");
}

if(weaponid == 38 && PlayerInfo[playerid][pAdmin] < 5)
{
return SendClientMessage(playerid, COLOR_GREY, "The minigun was disabled due to abuse.");
}


GivePlayerWeaponEx(targetid, weaponid);

SendClientMessageEx(targetid, COLOR_AQUA, "You have received a {00AA00}%s{33CCFF} from %s.", GetWeaponNameEx(weaponid), GetPlayerRPName(playerid));
SendAdminMessage(COLOR_LIGHTRED, "AdmCmd: %s has given a %s to %s.", GetPlayerRPName(playerid), GetWeaponNameEx(weaponid), GetPlayerRPName(targetid));

Log_Write("log_givegun", "%s (uid: %i) gives a %s to %s (uid: %i)", GetPlayerNameEx(playerid), PlayerInfo[playerid][pID], GetWeaponNameEx(weaponid), GetPlayerNameEx(targetid), PlayerInfo[targetid][pID]);
return 1;
}
Reply
#7

The function is called GivePlayerWeaponEx according to your command. Make it a public function and call it from the filterscript the same way you did with money.

pawn Код:
// filterscript:
givePlayerWeapon(playerid, weaponid)
{
    CallRemoteFunction("GivePlayerWeaponEx", "dd", playerid, weaponid);
}
Now replace at the filterscript `GivePlayerWeapon` with `givePlayerWeapon`.
Reply
#8

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
The function is called GivePlayerWeaponEx according to your command. Make it a public function and call it from the filterscript the same way you did with money.

pawn Код:
// filterscript:
givePlayerWeapon(playerid, weaponid)
{
    CallRemoteFunction("GivePlayerWeaponEx", "dd", playerid, weaponid);
}
Now replace at the filterscript `GivePlayerWeapon` with `givePlayerWeapon`.
Mate, can you please help me with this ?
https://sampforum.blast.hk/showthread.php?tid=659359
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)