Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Not sending an error message

 
  • 0 Vote(s) - 0 Average
Pawn Not sending an error message
Axitz
Offline

Burgershot Member
Posts: 13
Threads: 6
Joined: Apr 2021
Reputation: 0
Location: Malaysia
#1
2021-04-07, 02:32 PM (This post was last modified: 2021-04-07, 02:33 PM by Axitz.)
I have this problem when I use the other method, it does work but if I change it the way I wanted, it doesn't. Please help. 

This one does work.
PHP Code:
if(Vehicles[vehicleid][impounded] == 1) return SendClientMSG(playerid, COLOR_RED, "{ff6347}Error: Unable to spawn because it is impounded."); 

This one doesn't work. No Idea why.
PHP Code:
if(Vehicles[vehicleid][impounded] == 1) return SendClientMSG(playerid, COLOR_RED, "{ff6347}Error: Unable to spawn %s (ID: %d) because it is impounded.",GetVehicleName(Vehicles[vehicleid][vrID]), vehicleid); 
Radical
Offline

Burgershot Member
Posts: 66
Threads: 8
Joined: Dec 2020
Reputation: 8
Location: Iran
#2
2021-04-07, 04:26 PM
post your SendClientMSG function.
Axitz
Offline

Burgershot Member
Posts: 13
Threads: 6
Joined: Apr 2021
Reputation: 0
Location: Malaysia
#3
2021-04-07, 05:05 PM
(2021-04-07, 04:26 PM)Radical Wrote: post your SendClientMSG function.

PHP Code:
stock SendClientMSG(playerid, color, fstring[], {Float, _}:...)
{
    #define BYTES_PER_CELL 4
    // This is the number of parameters which are not variable that are passed
    // to this function (i.e. the number of named parameters).
    static const
        STATIC_ARGS = 3;
    // Get the number of variable arguments.
    new
        n = (numargs() - STATIC_ARGS) * BYTES_PER_CELL;
    if (n)
    {
        new
            message[128],
            arg_start,
            arg_end;

        // Load the real address of the last static parameter. Do this by
        // loading the address of the last known static parameter and then
        // adding the value of [FRM].
        #emit CONST.alt        fstring
        #emit LCTRL          5
        #emit ADD
        #emit STOR.S.pri      arg_start

        // Load the address of the last variable parameter. Do this by adding
        // the number of variable parameters on the value just loaded.
        #emit LOAD.S.alt      n
        #emit ADD
        #emit STOR.S.pri      arg_end

        // Push the variable arguments. This is done by loading the value of
        // each one in reverse order and pushing them. I'd love to be able to
        // rewrite this to use the values of pri and alt for comparison,
        // instead of having to constantly load and reload two variables.
        do
        {
            #emit LOAD.I
            #emit PUSH.pri
            arg_end -= BYTES_PER_CELL;
            #emit LOAD.S.pri    arg_end
        }
        while (arg_end > arg_start);

        // Push the static format parameters.
        #emit PUSH.S        fstring
        #emit PUSH.C        128
        #emit PUSH.ADR        message

        // Now push the number of arguments passed to format, including both
        // static and variable ones and call the function.
        n += BYTES_PER_CELL * 3;
        #emit PUSH.S        n
        #emit SYSREQ.C        format

        // Remove all data, including the return value, from the stack.
        n += BYTES_PER_CELL;
        #emit LCTRL          4
        #emit LOAD.S.alt      n
        #emit ADD
        #emit SCTRL          4

        return SendMessageToPlayer(playerid, color, message);
        //return print(message);
    }
    else
    {
        return SendMessageToPlayer(playerid, color, fstring);
        //return print(fstring);
    }
} 
destiezk
Offline

Burgershot Member
Posts: 41
Threads: 1
Joined: Feb 2021
Reputation: 3
Location: Hungary
#4
2021-04-07, 10:11 PM
Code:
#define SendClientMessageFormatted(%0,%1,%2,%3) do{new _string[128]; format(_string,sizeof(_string),%2,%3); SendClientMessage(%0,%1,_string);} while(FALSE)

if(Vehicles[vehicleid][impounded] == 1) return SendClientMessageFormatted(playerid, COLOR_RED, "{ff6347}Error: Unable to spawn %s (ID: %d) because it is impounded.",GetVehicleName(Vehicles[vehicleid][vrID]), vehicleid);

Try this.
Pinch
Offline

Burgershot Member
Posts: 299
Threads: 18
Joined: Apr 2019
Reputation: 19
Location: Belgrade, Serbia
#5
2021-04-07, 11:26 PM
Believe me and just replace your code with this one if you have YSI included:

Code:
if(Vehicles[vehicleid][impounded] == 1) return va_SendClientMessage(playerid, COLOR_RED, "{ff6347}Error: Unable to spawn %s (ID: %d) because it is impounded.",GetVehicleName(Vehicles[vehicleid][vrID]), vehicleid);
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
Axitz
Offline

Burgershot Member
Posts: 13
Threads: 6
Joined: Apr 2021
Reputation: 0
Location: Malaysia
#6
2021-04-08, 01:24 PM
I don't use YSI.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode