SA-MP Forums Archive
after learn what to do exactly with examples? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: after learn what to do exactly with examples? (/showthread.php?tid=110807)



after learn what to do exactly with examples? - Sfinx_17 - 28.11.2009

i learn a bit about if/elseif/else

in wiki it says allways a , b , c bla bla etc

ok for example if i want to make a code when a player disconnect ...for what help me those codes from wiki at all?
for ex this:
pawn Код:
new
  a = 5;
if(a == 5)
printf(" a is really 5)
ok i understand that a is really 5 so?
in my script what to do for example when a player disconnect to see reason ,etc?
i will make this?
pawn Код:
playerid = 5
if(playerid == 5)
printf(playerid is now 5)
i don't understand about what to make instead of those examples from wiki with a, b new a = 5; , etc.
plz help here somewone i will apreciate


Re: after learn what to do exactly with examples? - GTA_Rules - 28.11.2009

Let's say you want to check if playerid 5 disconnects from the server, you'd use something like this:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  if(playerid == 5)
  {
   print("the player who disconnected had the id 5");
  }
  else
  {
   print("the player who disconnected didn't have the id 5");
  }
  return 1;
}



Re: after learn what to do exactly with examples? - Sfinx_17 - 28.11.2009

ok Mathias good example.
but what ..in this pawn instead of putting playerid at "a" i can put what more things? this kind of stuff i don't understand ..you know what i mean?


Re: after learn what to do exactly with examples? - GTA_Rules - 28.11.2009

Yes, for example:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  new a = playerid; // you here declare the variable 'a' to be playerid.
  if(a == 5)
  {
   print("the player who disconnected had the id 5");
  }
  else
  {
   print("the player who disconnected didn't have the id 5");
  }
  return 1;
}




Re: after learn what to do exactly with examples? - Sfinx_17 - 28.11.2009

no no mathias you don't understand what i am trying to say is another thing...instead of that a, b example's code's what exist in wiki what else i can put in my script? for example
pawn Код:
new cjishere;
if(cjishere == me)
printf("cj is really me")
 return 1;



Re: after learn what to do exactly with examples? - Donny_k - 28.11.2009

Whatever you wish (within reason), it's just a statement. Once you have your statements sussed move onto loops (repeated statements kindof).

pawn Код:
for ( new i; i < 5; i ++ )
{
  //some code
}

//is the same as

if ( i == 0 ) {/*some code*/}
if ( i == 1 ) {/*some code*/}
if ( i == 2 ) {/*some code*/}
if ( i == 3 ) {/*some code*/}
if ( i == 4 ) {/*some code*/}
It's not exactly the same (seperate scopes) but it's kind of the same, the loop is doing the same thing but it runs one scope.

pawn Код:
//as I said the other day
function() //or if ( blah ) << statement
{
  //this is the scope here
}
Also it would be a good idea to figure out the different types of variables we use (not programming types, types as in a subdivision).

We have a few in Pawn, to start with the basics:

pawn Код:
new
  integer,
  char,
  string[],
  bool:boolean,
  Float:floating_point;
Learn how to use them, consult the pdf and Wiki (or ******).


Re: after learn what to do exactly with examples? - Sfinx_17 - 28.11.2009

plz explain what your sayng cause i don't understand what your trying to say donny
what to put instead of those (a == 5 for example?
(cj == me)?
or what i can named those chunck of codes?


Re: after learn what to do exactly with examples? - patchkinson - 28.11.2009

What he wants is instead of 5 is have playername
like if id 5 is called Sampplayer
he wants to
have print Sampplayer Disconnected
its not print(playerid ^^)
you have to learn strings, I will keep telling you, sfinx, that you are going to fast, you need to learn basics before going there, WTF!!


Re: after learn what to do exactly with examples? - Sfinx_17 - 28.11.2009

i allready learn basic in wiki ....wery carefull and wery slowlyy slowly


Re: after learn what to do exactly with examples? - patchkinson - 28.11.2009

if you say so, but you did not aknowledge everything! You really need,your mixing steps up!!