SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Little coding questions - For general minor queries 5 (https://forum.sa-mp.com/showthread.php?t=30938)

Kar 09/07/2010 06:35 AM

Re: Little coding questions - For general minor queries 5
 
this crashes the server when i try to spawn.

btw how did you get your thing into a pawn code? idk how with the new forum

public OnPlayerRequestSpawn(playerid)
{
new str[128];
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
if(!dini_Exists(pfile))
{
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
format(str, sizeof(str),"", Playername(playerid));
SendMsg(playerid, BRIGHTRED, "*SERVER: You Are Not Registered Please Register Using /Register [PASSWORD]!");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
return 0;
}
if(IsLogged[playerid] == 0)
{
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
SendMsg(playerid, BRIGHTRED, "*SERVER: THIS NAME IS REGISTERD PLEASE LOGIN /LOGIN [PASSWORD]");
format(str, sizeof(str),"", Playername(playerid));
SendMsg(playerid, YELLOW, "*SERVER: Registered Username:%s ");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
return 0;
}
return 1;
}

Shkelqimi 09/07/2010 08:51 AM

Re: Little coding questions - For general minor queries 5
 
Can someone help me please ! What I need is this: a checkpoint (entrance checkpoint) to Burger Shot in SF! And another checkpoint inside Burger Shot when player enters the checkpoint it will appear a dialog with input option to buy meal and heal up, and ofc a exit checkpoint !
how it should look like some screenshots:
1) http://img196.imageshack.us/img196/3269/32169719.png
2) http://img38.imageshack.us/img38/8229/52454761.png
3) http://img341.imageshack.us/img341/8521/14350512.png

Hiddos 09/07/2010 10:16 AM

Re: Little coding questions - For general minor queries 5
 
Quote:

Originally Posted by Kar (Post 743837)
this crashes the server when i try to spawn.

btw how did you get your thing into a pawn code? idk how with the new forum

You're fucking up strings, like you aren't placing anything in strings, sending strings without knowing what you're actually doing, etc.


public OnPlayerRequestSpawn(playerid)
{
new str[128];
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
if(!dini_Exists(pfile))
{
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
SendMsg(playerid, BRIGHTRED, "*SERVER: You Are Not Registered Please Register Using /Register [PASSWORD]!");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
return 0;
}
if(IsLogged[playerid] == 0)
{
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
SendMsg(playerid, BRIGHTRED, "*SERVER: THIS NAME IS REGISTERD PLEASE LOGIN /LOGIN [PASSWORD]");
format(str, sizeof(str),"Registered username: %s", Playername(playerid));
SendMsg(playerid, YELLOW, str);
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
return 0;
}
return 1;
}[/pawn]

XpanD 09/07/2010 11:23 AM

Re: Little coding questions - For general minor queries 5
 
Hi all!

I am making a combination filterscript which uses commands from quite a few different admin scripts (complete with credits to the makers :)). I took a command named /miniguns from LAdmin4v2, I believe it was. The command shows who has a minigun on a single line of text, followed by the ammo that player has.

The command works fine, but the thing is once there are more than 4-6 people on (armed with miniguns), the text in the string gets cut off, making me and all other admins using the command unable to see if anybody else apart from those first few people has a minigun.

What I would want to do is make this script show miniguns in three or four lines, each line showing 4 people. Also, I would also want this command to not show additional lines if there are no people with miniguns to fill them up with.

I am using DCMD without the sscanf thingy, as I haven't looked into that yet. Also, I am rather new to scripting (though I have made a few simple commands before, such as a command to set a player's time and weather).

How would I do this? The code is below:

pawn Code:
dcmd_miniguns(playerid,params[])
{
    #pragma unused params
    if (AccountInfo[playerid][AdminLevel] >= 1 || IsPlayerAdmin(playerid))
    {
        new bool:First2 = false, Count, string[128], i, slot, weap, ammo;
        for(i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                for(slot = 0; slot < 14; slot++)
                {
                    GetPlayerWeaponData(i, slot, weap, ammo);
                    if(ammo != 0 && weap == 38)
                    {
                        Count++;
                        if(!First2) { format(string, sizeof(string), "Minigun: (%d)%s(ammo%d)", i, PlayerName2(i), ammo); First2 = true; }
                        else format(string,sizeof(string),"%s, (%d)%s(ammo%d) ",string, i, PlayerName2(i), ammo);
                    }
                }
            }
        }
        if(Count == 0) return SendClientMessage(playerid,COLOR_WHITE,"No players have a minigun!"); else return SendClientMessage(playerid,COLOR_WHITE,string);
    } else return SendClientMessage(playerid,COLOR_RED,"ERROR: You need to be level 1 to use this command.");
}

Thanks in advance! :)

Audiophr3ak 09/07/2010 02:03 PM

Re: Little coding questions - For general minor queries 5
 
How to remove that spawn menu from the script, watch the screen

http://img85.imageshack.us/gal.php?g=samp013px.png

Grim_ 09/07/2010 02:04 PM

Re: Little coding questions - For general minor queries 5
 
@Audiophr3ak: It's not possible.

Rizard 09/07/2010 03:14 PM

Re: Little coding questions - For general minor queries 5
 
fellow scripters,

Since I decided to add a /vote system to my server (7/09) I've been searching on how to work with array strings or string arrays w/e ... with not an obscene amount of succes (just found enums, and a few things in pawn guide.pdf .. )

so the problem:
I like to have all the arena names (yes, strings with spaces) linked to a vote count (int/number/...). AND being able to search in the array for the arena name (string) with the most vote counts.

I believe the theory is kinda correct??? BUT please help me along on how to put this into "pawn".

thnx

Simon 11/07/2010 10:04 AM

Re: Little coding questions - For general minor queries 5
 
You mean like this?

pawn Code:
const MaxArenas = 128;

enum VotePlaceStructure
{
    VotePlaceName[32],
    VotePlaceVotes,
};

new VoteData[MaxArenas][VotePlaceStructure];

public OnGameModeInit()
{
    VoteData[0][VotePlaceName] = "Derby";
    VoteData[1][VotePlaceName] = "Cluckin' Bell Cock Fight";
    VoteData[2][VotePlaceName] = "Burger Shot Rock Hard Buns Fight";
    // etc
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    // etc
    // search for place name in VoteData array using strcmp or strfind and a loop, save array index to "i"
    VoteData[i][VotePlaceVotes] ++;
    // etc
}

BloodyEric 11/07/2010 05:37 PM

Re: Little coding questions - For general minor queries 5
 
What is the limit of listitems in dialogs? (DIALOG_STYLE_LIST)

[XST]O_x 12/07/2010 09:19 AM

Re: Little coding questions - For general minor queries 5
 
I have a question.
If I'd do:
pawn Code:
new Float:ax,Float:ay,Float:az,id; GetPlayerPos(id,ax,ay,az);
    //arrest command continues from here..

    if(IsPlayerInRangeOfPoint(playerid,10,ax,ay,az);

Or:
pawn Code:
if(GetDistanceBetweenPlayers(playerid,id) == 10)

Will it affect the same?


All times are GMT. The time now is 05:40 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.