Update new.pwn
#1

Well these is an easy suggestion but its a needed one... Current new.pwn is totally outdated... I just think by default there have to be all callback functions and default values they return... I understand we can open a_samp.inc and check forwards but then we dont know what callback must return (And does it have to return anything at all)

I did update my new.pwn but i put everywhere return 1; (And then things like dialogs get bugged...) So including updated new.pwn in server package would be awesome.
Reply
#2

I though about it while ago aswell, especially for new scripters, all callbacks should be in the in new.pwn file.
Reply
#3

You happy yet?

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 0;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}

public OnVehicleSpawn(playerid)
{
    return 1;
}

public OnVehicleDeath(playerid)
{
    return 1;
}
i really don't know why new.pwn needs to be changed at all.

I don't even use new.pwn, I honestly just delete it all. Good scripters should be able to atleast properly write out a function heading, and properly return a value accordingly.

And if you are struggling to locate a proper function / callback, the wiki is pretty user-friendly indeed. So, basically, - after searching through the wiki and finding your answer you'll have used barely any time at all as appose to needing to look all through a lengthy new.pwn.

tl/tr: it is ok the way it is
Reply
#4

Lets take for sake of the argument only one callback. I dont see OnPlayerTakeDamage...how can i know that it exists at all? How can i know what parameters it has and what value it must return to work properly?

new.pwn was populated with all callbacks for a good reason, you dont need some of them? Feel free to delete them (Its way easier than to add them).

By the way here is example of OnPlayerEditAttachedObject parameters:
pawn Код:
public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ)
{
    //These callback does not handle returns
}
That is some callback...let me guess...you know how to write that heading function along with all parameters and if you dont you will visit wiki... Oh wait! What if someone doesn't even know that such callback exists?! Oh right...its their fault they didnt read whole wiki...
Reply
#5

https://sampwiki.blast.hk/wiki/Category:Scripting_Functions

https://sampwiki.blast.hk/wiki/Category:Scripting_Callbacks
Reply
#6

Would be nice with an update, but I have never used new.pwn myself.
Reply
#7

Here's an updated version of new.pwn(all callbacks) for those who are looking for - https://github.com/Lordzy/Updated-new.pwn

NOTE : This script is compatible only for the current latest R version of SA-MP, which is 0.3z-R4. I'll be updating it when SA-MP releases the R version of SA-MP 0.3.7.
Reply
#8

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
Here's an updated version of new.pwn(all callbacks) for those who are looking for - https://github.com/Lordzy/Updated-new.pwn

NOTE : This script is compatible only for the current latest R version of SA-MP, which is 0.3z-R4. I'll be updating it when SA-MP releases the R version of SA-MP 0.3.7.
OnDialogResponse you are returning 1, while callback expects return 0 in order to call same callback in FilterScripts.

These is one of the reasons why i suggested these file to be updated (Officially).
Reply
#9

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
OnDialogResponse you are returning 1, while callback expects return 0 in order to call same callback in FilterScripts.

These is one of the reasons why i suggested these file to be updated (Officially).
Thanks for noting, fixed.

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
Lets take for sake of the argument only one callback. I dont see OnPlayerTakeDamage...how can i know that it exists at all? How can i know what parameters it has and what value it must return to work properly?

new.pwn was populated with all callbacks for a good reason, you dont need some of them? Feel free to delete them (Its way easier than to add them).

By the way here is example of OnPlayerEditAttachedObject parameters:
pawn Код:
public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ)
{
    //These callback does not handle returns
}
That is some callback...let me guess...you know how to write that heading function along with all parameters and if you dont you will visit wiki... Oh wait! What if someone doesn't even know that such callback exists?! Oh right...its their fault they didnt read whole wiki...
According to this post, you could create fake natives of callback names to include their parameter and so they'll highlight them.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)