SA-MP Forums Archive
OnPlayerSpawn problem - 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: OnPlayerSpawn problem (/showthread.php?tid=382537)



OnPlayerSpawn problem - benel1 - 03.10.2012

Hello ..
i have a problem in this public:
OnPlayerSpawn
the problem:
When I died instantly created
i only get a pistol and here the codes: - can you tell me what is the problem ?
pawn Код:
new RandomWeapons[] =
{
    24,
    27,
    29,
    31,
    4
};
pawn Код:
public OnPlayerSpawn(playerid)
   {
    GivePlayerWeapon(playerid, RandomWeapons[random(sizeof(RandomWeapons))], 500);
    GivePlayerWeapon(playerid, RandomWeapons[random(sizeof(RandomWeapons))], 500);
    GivePlayerWeapon(playerid, RandomWeapons[random(sizeof(RandomWeapons))], 500);
   }
    return 1;
   }
Sorry for my bad english it's GT [****** translate]


Re : OnPlayerSpawn problem - lelemaster - 03.10.2012

pawn Код:
new RandomWeapons[5] =
{
    24,
    27,
    29,
    31,
    4
};
It's 5 or 6, I don't remember, just give it a try.


Re: Re : OnPlayerSpawn problem - benel1 - 04.10.2012

Quote:
Originally Posted by lelemaster
Посмотреть сообщение
pawn Код:
new RandomWeapons[5] =
{
    24,
    27,
    29,
    31,
    4
};
It's 5 or 6, I don't remember, just give it a try.
No worked ...
In any case thanks for the experience


Re : OnPlayerSpawn problem - lelemaster - 04.10.2012

Actually, what does it do, not giving weapon, always weapon 24(Deagle), or what, same problem that you mentioned.

Could you try to translate it in different words, I don't really understand when you say:

When I died instantly created
i only get a pistol and here the codes: - can you tell me what is the problem ?


Re: OnPlayerSpawn problem - SwisherSweet - 04.10.2012

pawn Код:
public OnPlayerSpawn(playerid)
{
    GivePlayerWeapon(playerid, RandomWeapons[random(sizeof(RandomWeapons))], 500);
    GivePlayerWeapon(playerid, RandomWeapons[random(sizeof(RandomWeapons))], 500);
    GivePlayerWeapon(playerid, RandomWeapons[random(sizeof(RandomWeapons))], 500);
    return 1;
}
I'm not really sure but you can try this also if i remember good
pawn Код:
public OnPlayerSpawn(playerid)
{
    GivePlayerWeapon(playerid, RandomWeapons, 500);
    GivePlayerWeapon(playerid, RandomWeapons, 500);
    GivePlayerWeapon(playerid, RandomWeapons, 500);
    return 1;
}
I Think Should Also work!


Re: OnPlayerSpawn problem - [FAT]Klabauter[LST] - 04.10.2012

I think that it is giving you pistol every time because it is the first weapon you listed.

I tested this and it works, but it is still possible to get the same weapon more than once.
I don't know how to make it give 3 different weapons every time

PHP код:
stock giverandomweap(playerid)
{
    new 
RandomWeapons random(5);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid24500);
        case 
1: return GivePlayerWeapon(playerid27500);
        case 
3: return GivePlayerWeapon(playerid29500);
        case 
4: return GivePlayerWeapon(playerid31500);
        case 
5: return GivePlayerWeapon(playerid41); // you can't have more than 1 knife
    
}
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    
giverandomweap(playerid);
    
giverandomweap(playerid);
    
giverandomweap(playerid);
    return 
1;

I only know how to give a random weapon in each slot, I put assault and rifles together (seemed better that way)
go ahead and use this if you want:

PHP код:
stock giverandompistol(playerid)
{
    new 
RandomWeapons random(3);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid24150);
        case 
1: return GivePlayerWeapon(playerid23250);
        case 
2: return GivePlayerWeapon(playerid22350);
    }
    return 
1;
}
stock giverandomshotty(playerid)
{
    new 
RandomWeapons random(3);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid25300);
        case 
1: return GivePlayerWeapon(playerid27200);
        case 
2: return GivePlayerWeapon(playerid26100);
    }
    return 
1;
}
stock giverandomsmg(playerid)
{
    new 
RandomWeapons random(3);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid28500);
        case 
1: return GivePlayerWeapon(playerid32500);
        case 
2: return GivePlayerWeapon(playerid29500);
    }
    return 
1;
}
stock giverandomrifle(playerid)
{
    new 
RandomWeapons random(4);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid3475);
        case 
1: return GivePlayerWeapon(playerid33200);
        case 
2: return GivePlayerWeapon(playerid30300);
        case 
3: return GivePlayerWeapon(playerid31250);
    }
    return 
1;
}
stock giverandommelee(playerid)
{
    new 
RandomWeapons random(15);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid11);
        case 
1: return GivePlayerWeapon(playerid21);
        case 
2: return GivePlayerWeapon(playerid31);
        case 
3: return GivePlayerWeapon(playerid41);
        case 
4: return GivePlayerWeapon(playerid51);
        case 
5: return GivePlayerWeapon(playerid61);
        case 
6: return GivePlayerWeapon(playerid71);
        case 
7: return GivePlayerWeapon(playerid81);
        case 
8: return GivePlayerWeapon(playerid91);
        case 
9: return GivePlayerWeapon(playerid101);
        case 
10: return GivePlayerWeapon(playerid111);
        case 
11: return GivePlayerWeapon(playerid121);
        case 
12: return GivePlayerWeapon(playerid131);
        case 
13: return GivePlayerWeapon(playerid141);
        case 
14: return GivePlayerWeapon(playerid151);
    }
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    
giverandompistol(playerid);
    
giverandomshotty(playerid);
    
giverandomsmg(playerid);
    
giverandomrifle(playerid);
    
giverandommelee(playerid);
    return 
1;




Re: OnPlayerSpawn problem - benel1 - 04.10.2012

Quote:
Originally Posted by lelemaster
Посмотреть сообщение
Actually, what does it do, not giving weapon, always weapon 24(Deagle), or what, same problem that you mentioned.

Could you try to translate it in different words, I don't really understand when you say:

When I died instantly created
i only get a pistol and here the codes: - can you tell me what is the problem ?
When I come to life only gives me a pistol and not the random weapons ..
And I tried a few times ..

Quote:
Originally Posted by Aveger
Посмотреть сообщение
pawn Код:
public OnPlayerSpawn(playerid)
{
    GivePlayerWeapon(playerid, RandomWeapons[random(sizeof(RandomWeapons))], 500);
    GivePlayerWeapon(playerid, RandomWeapons[random(sizeof(RandomWeapons))], 500);
    GivePlayerWeapon(playerid, RandomWeapons[random(sizeof(RandomWeapons))], 500);
    return 1;
}
I'm not really sure but you can try this also if i remember good
pawn Код:
public OnPlayerSpawn(playerid)
{
    GivePlayerWeapon(playerid, RandomWeapons, 500);
    GivePlayerWeapon(playerid, RandomWeapons, 500);
    GivePlayerWeapon(playerid, RandomWeapons, 500);
    return 1;
}
I Think Should Also work!
No worked ..
pawn Код:
C:\Documents and Settings\User\Desktop\FXP отшлеъ м\TeamWar.pwn(154) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\User\Desktop\FXP отшлеъ м\TeamWar.pwn(155) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\User\Desktop\FXP отшлеъ м\TeamWar.pwn(156) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
Quote:
Originally Posted by [FAT]Klabauter[LST]
Посмотреть сообщение
I think that it is giving you pistol every time because it is the first weapon you listed.

I tested this and it works, but it is still possible to get the same weapon more than once.
I don't know how to make it give 3 different weapons every time

PHP код:
stock giverandomweap(playerid)
{
    new 
RandomWeapons random(5);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid24500);
        case 
1: return GivePlayerWeapon(playerid27500);
        case 
3: return GivePlayerWeapon(playerid29500);
        case 
4: return GivePlayerWeapon(playerid31500);
        case 
5: return GivePlayerWeapon(playerid41); // you can't have more than 1 knife
    
}
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    
giverandomweap(playerid);
    
giverandomweap(playerid);
    
giverandomweap(playerid);
    return 
1;

I only know how to give a random weapon in each slot, I put assault and rifles together (seemed better that way)
go ahead and use this if you want:

PHP код:
stock giverandompistol(playerid)
{
    new 
RandomWeapons random(3);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid24150);
        case 
1: return GivePlayerWeapon(playerid23250);
        case 
2: return GivePlayerWeapon(playerid22350);
    }
    return 
1;
}
stock giverandomshotty(playerid)
{
    new 
RandomWeapons random(3);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid25300);
        case 
1: return GivePlayerWeapon(playerid27200);
        case 
2: return GivePlayerWeapon(playerid26100);
    }
    return 
1;
}
stock giverandomsmg(playerid)
{
    new 
RandomWeapons random(3);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid28500);
        case 
1: return GivePlayerWeapon(playerid32500);
        case 
2: return GivePlayerWeapon(playerid29500);
    }
    return 
1;
}
stock giverandomrifle(playerid)
{
    new 
RandomWeapons random(4);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid3475);
        case 
1: return GivePlayerWeapon(playerid33200);
        case 
2: return GivePlayerWeapon(playerid30300);
        case 
3: return GivePlayerWeapon(playerid31250);
    }
    return 
1;
}
stock giverandommelee(playerid)
{
    new 
RandomWeapons random(15);
    switch(
RandomWeapons)
    {
        case 
0: return GivePlayerWeapon(playerid11);
        case 
1: return GivePlayerWeapon(playerid21);
        case 
2: return GivePlayerWeapon(playerid31);
        case 
3: return GivePlayerWeapon(playerid41);
        case 
4: return GivePlayerWeapon(playerid51);
        case 
5: return GivePlayerWeapon(playerid61);
        case 
6: return GivePlayerWeapon(playerid71);
        case 
7: return GivePlayerWeapon(playerid81);
        case 
8: return GivePlayerWeapon(playerid91);
        case 
9: return GivePlayerWeapon(playerid101);
        case 
10: return GivePlayerWeapon(playerid111);
        case 
11: return GivePlayerWeapon(playerid121);
        case 
12: return GivePlayerWeapon(playerid131);
        case 
13: return GivePlayerWeapon(playerid141);
        case 
14: return GivePlayerWeapon(playerid151);
    }
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    
giverandompistol(playerid);
    
giverandomshotty(playerid);
    
giverandomsmg(playerid);
    
giverandomrifle(playerid);
    
giverandommelee(playerid);
    return 
1;

No worked ..


Re: OnPlayerSpawn problem - Nirzor - 04.10.2012

Maybe you have some problems in this coding thing

24,
bla,
bla,
bla

should'nt there be ;


Re: OnPlayerSpawn problem - [FAT]Klabauter[LST] - 04.10.2012

I tested both of those scripts I posted and they both work.

Maybe you are putting them both together? Only use one of them.


Re: OnPlayerSpawn problem - benel1 - 04.10.2012

Quote:
Originally Posted by Nirzor
Посмотреть сообщение
Maybe you have some problems in this coding thing

24,
bla,
bla,
bla

should'nt there be ;
I did not understand what you mean

Quote:
Originally Posted by [FAT]Klabauter[LST]
Посмотреть сообщение
I tested both of those scripts I posted and they both work.

Maybe you are putting them both together? Only use one of them.
I did not understand what you mean