SA-MP Forums Archive
Returning a CMD! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Returning a CMD! (/showthread.php?tid=601772)



Returning a CMD! - Compiler - 26.02.2016

I have a antifall command. Its fuction is to only Send the Player a Message but it also has a Variable and the Variable has the main function. When I do /antifall, it Send me the Message and the Varible performs its function but when I use return CMD_antifall( playerid ), it Sends me the message but the variable doesnt perform its function but the variable becomes 1 when it is 0 and 0 when it is 1. Why isnt it performing its function? Can anybody help!


Re: Returning a CMD! - K0P - 26.02.2016

Lol,did you made any function for it?


Re: Returning a CMD! - SyS - 26.02.2016

show code i think u may have returned multiple (semantic error bro)


Re: Returning a CMD! - Compiler - 28.02.2016

I returned the Command while making a /settings command. Here is the Code:

Command:
PHP Code:
CMD:antifallplayerid )
{
 if(
Act[playerid] == 0)
    {
     
Act[playerid] = 1;
        
SendClientMessage(playerid,-1,">>>"GREEN" Antifall Enabled!");
    }
    else if(
Act[playerid] == 1)
    {
        
SendClientMessage(playerid,-1,">>>"RED" Antifall Disabled!");
        
Act[playerid] = 0;
    }
    return 
1;

Function of the Variable:
PHP Code:
public OnPlayerStateChange(playeridnewstateoldstate)
{
        if(
Act[playerid] == 1)
        {
                if(
oldstate == PLAYER_STATE_DRIVER)
                {
                        if(
newstate == PLAYER_STATE_ONFOOT)
                        {
                                if(
InCar[playerid] == 1)
                                {
                                        
PutPlayerInVehicle(playeridWhatCar[playerid], Driver);
                                }
                        }
                }
                if(
oldstate == PLAYER_STATE_PASSENGER)
                {
                        if(
newstate == PLAYER_STATE_ONFOOT)
                        {
                                if(
InCar[playerid] == 1)
                                {
                                        
PutPlayerInVehicle(playeridWhatCar[playerid], Passanger);
                                }
                        }
                }
                if(
oldstate == PLAYER_STATE_ONFOOT)
                {
                        if(
newstate == PLAYER_STATE_DRIVER || PLAYER_STATE_PASSENGER)
                        {
                                
InCar[playerid] = 1;
                                
WhatCar[playerid] = GetPlayerVehicleID(playerid);
                        }
                }
        }
        return 
1;

The Settings Stock:
PHP Code:
stock ShowSettings (playerid)
{
    new 
str[350];
    new 
Antifal[40];
    if (
Act[playerid] == 1format(Antifal40GREEN"Enabled");
    if (
Act[playerid] == 0format(Antifal40RED"Disabled");
    
format(strsizeof(str), "Antifall (%s{FFFFFF})"Antifal);
    
ShowPlayerDialog(playeridDIALOGID_SETTINGSDIALOG_STYLE_LISTREDORANGE">> {FFFFFF}Account Settings"str"OK""Cancel");
    return 
1;

The Place where the command is returned:
PHP Code:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if (
dialogid == DIALOGID_SETTINGS) {
        if (!
response) return 1;
        if (
response) { Timer1[playerid] = SetTimerEx("Settings"50true"i"playerid);
            switch (
listitem)
            {
                case 
0:
                {
                    return 
CMD_godplayerid );
                }
                case 
1:
                {
                     return 
CMD_antifallplayerid );
                }
            }
        }
    }
    return 
1;

Please help me!


Re: Returning a CMD! - SyS - 28.02.2016

Try it changing CMD_antifall to cmd_antifall im not sure though
Edit u made it like that 0 to become 1 and when 1 to become 0 so wat is problem??